Part Number Hot Search : 
RB09331J G40TSM NH02L MBR330 DBF150G 4559B AN8090S OP183
Product Description
Full Text Search
 

To Download SAFC165H-LFV13 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  c165h embedded c166 with usart, iom-2 and hdlc support version 1.3 data sheet, ds 1, april 2001 wired communications never stop thinking.
edition 2001-04-01 published by infineon technologies ag, st.-martin-strasse 53, d-81541 mnchen, germany ? infineon technologies ag 2001. all rights reserved. attention please! the information herein is given to describe certain components and shall not be considered as warranted characteristics. terms of delivery and rights to technical change reserved. we hereby disclaim any and all warranties, including but not limited to warranties of non-infringement, regarding circuits, descriptions and charts stated herein. infineon technologies is an approved cecc manufacturer. information for further information on technology, delivery terms and conditions and prices please contact your nearest infineon technologies office in germany or our infineon technologies representatives worldwide (see address list). warnings due to technical requirements components may contain dangerous substances. for information on the types in question please contact your nearest infineon technologies office. infineon technologies components may only be used in life-support devices or systems with the express written approval of infineon technologies, if a failure of such components can reasonably be expected to cause the failure of that life-support device or system, or to affect the safety or effectiveness of that device or system. life support devices or systems are intended to be implanted in the human body, or to support and/or maintain and sustain and/or protect human life. if they fail, it is reasonable to assume that the health of the user or other persons may be endangered.
wired communications c165h embedded c166 with usart, iom-2 and hdlc support version 1.3 data sheet, ds 1, april 2001 never stop thinking.
for questions on technology, delivery and prices please contact the infineon technologies offices in germany or the infineon technologies companies and representatives worldwide: see our webpage at http://www.infineon.com c165h revision history: 2001-04-01 ds 1 previous version: this is the first non-preliminary version. 1) 1) all previous distributed versions are preliminary . they have been replaced by this version. page subjects (major changes since last revision)
c165h page data sheet 2001-04-19 table of contents 1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.1 key features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 1.2 logic symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 1.3 pinning diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 1.4 typical applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 1.4.1 isdn nt and pbx applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2 pin descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.1 c165h pin diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.2 c165h pin definitions and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3 architectural overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 3.1 basic cpu concepts and optimizations . . . . . . . . . . . . . . . . . . . . . . . . . . 29 3.2 on-chip system resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 3.3 clock generation concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 3.4 on-chip peripheral blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 3.5 protected bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 4 memory organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 4.1 internal ram and sfr area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 4.2 external memory space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 4.3 crossing memory boundaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 5 central processor unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 5.1 instruction pipelining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 5.2 bit-handling and bit-protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 5.3 instruction state times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5.4 cpu special function registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5.5 pec - extension of functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 6 interrupt and trap functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 6.1 interrupt system structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 6.2 interrupt control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 6.3 operation of the pec channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 6.4 prioritization of interrupt and pec service requests . . . . . . . . . . . . . . . 105 6.5 saving the status during interrupt service . . . . . . . . . . . . . . . . . . . . . . . 108 6.6 interrupt response times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 6.7 pec response times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 6.8 external interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 6.8.1 fast external interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 6.8.2 external interrupt source control . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 6.8.3 interrupt subnode control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 6.8.4 the interrupt control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 6.9 trap functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
c165h page data sheet 2001-04-19 table of contents 7 parallel ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 7.1 port0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 7.1.1 alternate functions of port0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 7.2 port1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 7.2.1 alternate functions of port1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 7.3 port2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 7.3.1 alternate functions of port2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 7.4 port3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 7.4.1 alternate functions of port3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 7.5 port4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 7.5.1 alternate functions of port4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 7.6 port6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 7.6.1 alternate functions of port6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 7.7 port7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 8 dedicated pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 9 external bus interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 9.1 external bus modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 9.2 programmable bus characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 9.3 ready controlled bus cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 9.4 controlling the external bus controller . . . . . . . . . . . . . . . . . . . . . . . . . . 183 9.5 ebc idle state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 9.6 external bus arbitration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 9.7 xbus interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 9.8 initialization of the c165h?s x-peripherals . . . . . . . . . . . . . . . . . . . . . . . . 199 10 general purpose timer unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 10.1 kernel description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 10.1.1 functional description of timer block 1 . . . . . . . . . . . . . . . . . . . . . . . 201 10.1.1.1 core timer t3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 10.1.1.2 auxiliary timers t2 and t4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 10.1.1.3 timer concatenation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 10.1.2 functional description of timer block 2 . . . . . . . . . . . . . . . . . . . . . . . 218 10.1.2.1 core timer t6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 10.1.2.2 auxiliary timer t5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 10.1.2.3 timer concatenation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 10.1.3 gpt register set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 11 asynchronous/synchr. serial interface . . . . . . . . . . . . . . . . . . . . . . . . 238 11.1 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 11.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 11.1.2 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 11.1.3 register description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 11.1.4 general operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
c165h page data sheet 2001-04-19 table of contents 11.1.5 asynchronous operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 11.1.5.1 asynchronous data frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 11.1.5.2 asynchronous transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 11.1.5.3 asynchronous reception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 11.1.5.4 irda mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 11.1.5.5 rxd/txd data path selection in asynchronous modes . . . . . . . . . 259 11.1.6 synchronous operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 11.1.6.1 synchronous transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 11.1.6.2 synchronous reception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 11.1.6.3 synchronous timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 11.1.7 baudrate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 11.1.7.1 baudrates in asynchronous mode . . . . . . . . . . . . . . . . . . . . . . . . . . 264 11.1.7.2 baudrates in synchronous mode . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 11.1.8 autobaud detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 11.1.8.1 general operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 11.1.8.2 serial frames for autobaud detection . . . . . . . . . . . . . . . . . . . . . . . 270 11.1.8.3 baudrate selection and calculation . . . . . . . . . . . . . . . . . . . . . . . . . 272 11.1.8.4 overwriting registers on successful autobaud detection . . . . . . . 274 11.1.9 hardware error detection capabilities . . . . . . . . . . . . . . . . . . . . . . . . 275 11.1.10 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 12 real time clock (rtc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 12.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 12.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 12.1.2 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 12.2 function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 12.2.1 rtc block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 12.2.2 rtc control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 12.2.3 system clock operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 12.2.4 cyclic interrupt generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 12.2.5 alarm interrupt generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 12.2.6 48-bit timer operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 12.2.7 defining the rtc time base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 12.2.8 increased rtc accuracy through software correction . . . . . . . . . . . . 283 12.2.9 hardware dependend rtc accuracy . . . . . . . . . . . . . . . . . . . . . . . . . 283 12.2.10 interrupt sub node rtcisnc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 12.2.11 rtc disable functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 12.2.12 register definition of rtc module . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 13 high-speed synchronous serial interface . . . . . . . . . . . . . . . . . . . . . 290 13.1 full-duplex operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 13.2 half duplex operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 13.3 baud rate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 13.4 error detection mechanisms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
c165h page data sheet 2001-04-19 table of contents 13.5 ssc interrupt control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 14 iom-2 interface controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 14.1 iom-2 and pcm frame structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 14.1.1 definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 14.1.1.1 frame structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 14.1.1.2 hdlc channels on the iom-2: b1, b2, d1, d2 . . . . . . . . . . . . . . . . 307 14.1.2 pcm mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 14.1.3 terminal mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 14.1.4 linecard mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 14.2 iom-2 handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 14.3 iom-2 monitor handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 14.3.1 handshake procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 14.3.2 abort procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 14.3.3 monitor interrupt logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 14.4 c/i channel handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 14.4.1 c/i0 - command/indication 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 14.4.2 c/i1 - command/indication 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 14.4.3 cic interrupt logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 14.4.4 d-channel access control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 14.4.4.1 tic bus d-channel access control for hdlc-2 controller . . . . . . . 320 14.5 controller data access handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 14.5.1 description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 14.5.2 looping and shifting data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323 14.5.3 monitoring data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 14.5.4 synchronous transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 14.6 bus activation / deactivation (power down) . . . . . . . . . . . . . . . . . . . . . . 329 14.6.1 deactivation request, downstream (c165h) to upstream . . . . . . . . . 330 14.6.2 deactivation, upstream to downstream (c165h) . . . . . . . . . . . . . . . . 331 14.6.3 activation request, downstream (c165h) to upstream . . . . . . . . . . . 331 14.6.4 activation, upstream to downstream (c165h) . . . . . . . . . . . . . . . . . . 331 14.7 hdlc controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 14.7.1 message transfer modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 14.7.1.1 non-auto mode (mds2-0 = ? 01x ? ) . . . . . . . . . . . . . . . . . . . . . . . . . . 333 14.7.1.2 transparent mode 0 (mds2-0 = ? 110 ? ). . . . . . . . . . . . . . . . . . . . . . . 333 14.7.1.3 transparent mode 1 (mds2-0 = ? 111 ? ). . . . . . . . . . . . . . . . . . . . . . . 333 14.7.1.4 transparent mode 2 (mds2-0 = ? 101 ? ). . . . . . . . . . . . . . . . . . . . . . . 334 14.7.1.5 extended transparent mode (mds2-0 = ? 100 ? ). . . . . . . . . . . . . . . . 334 14.7.2 data reception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334 14.7.2.1 general description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334 14.7.2.2 possible error conditions during reception of frames . . . . . . . . . . 335 14.7.2.3 receive frame structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 14.7.3 data transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
c165h page data sheet 2001-04-19 table of contents 14.7.3.1 general description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 14.7.3.2 possible error conditions during transmission of frames . . . . . . . 339 14.7.3.3 transmit frame structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 14.7.4 general access to iom-2 channels . . . . . . . . . . . . . . . . . . . . . . . . . . 340 14.7.5 extended transparent mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340 14.7.5.1 transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 14.7.5.2 receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 14.7.6 hdlc controller interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 14.7.6.1 general hdlc interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 14.7.6.2 hdlc transmit/receive fifo interrupt . . . . . . . . . . . . . . . . . . . . . 342 14.7.6.3 interrupt generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 14.8 iom-2/hdlc controller register set . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 14.8.1 register description format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 14.8.2 register table ordered by address . . . . . . . . . . . . . . . . . . . . . . . . . . . 344 14.8.3 detailed register description ordered by address . . . . . . . . . . . . . . . 349 14.8.4 hdlc-channel registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 15 watchdog timer (wdt) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 15.1 operation of the watchdog timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390 16 bootstrap loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393 17 system reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398 17.1 system startup configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405 18 power reduction modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410 18.1 idle mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410 18.2 power down mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412 18.3 status of output pins during idle and power down mode . . . . . . . . . . . . 412 18.4 extended power management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414 18.4.1 sleep mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415 19 system control unit (cscu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418 19.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418 19.2 operational overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418 19.2.1 overview of cscu submodules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418 19.3 xbus peripheral configuration block . . . . . . . . . . . . . . . . . . . . . . . . . . . 420 19.4 system control block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421 19.4.1 register write protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421 19.4.2 clock output frequency control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425 19.5 peripheral management module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 19.6 identification registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430 19.6.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430 19.6.2 id register description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430
c165h page data sheet 2001-04-19 table of contents 20 system programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 20.1 stack operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 20.2 register banking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440 20.3 procedure call entry and exit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441 20.4 table searching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443 20.5 peripheral control and interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444 20.6 floating point support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444 20.7 trap/interrupt entry and exit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444 20.8 unseparable instruction sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . 445 20.9 overriding the dpp addressing mechanism . . . . . . . . . . . . . . . . . . . . . 445 20.10 pits, traps and mines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447 21 register set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448 21.1 register description format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448 21.2 cpu general purpose registers (gprs) . . . . . . . . . . . . . . . . . . . . . . . . 449 21.3 special function registers ordered by address . . . . . . . . . . . . . . . . . . . 450 21.4 special function registers ordered by name . . . . . . . . . . . . . . . . . . . . . 458 21.5 special notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466 22 instruction set summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467 23 ac/dc characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471 23.1 absolute maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471 23.2 recommended operating conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . 471 23.3 dc characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471 23.4 failsafe operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473 23.5 testing waveforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474 23.6 ac characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474 23.6.1 definition of internal timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475 23.6.2 system reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476 23.6.3 external clock drive xtal1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477 23.6.4 iom-2 interface timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478 23.6.5 jtag interface timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480 23.7 asynchronous bus timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481 23.7.1 memory cycle variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481 23.7.1.1 ac characteristics, multiplexed bus . . . . . . . . . . . . . . . . . . . . . . . . 481 23.7.1.2 ac characteristics, demultiplexed bus . . . . . . . . . . . . . . . . . . . . . . 488 23.7.1.3 ac characteristics, clkout and ready . . . . . . . . . . . . . . . . . . . 495 24 package outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497
p-tqfp-144 data sheet 11 2001-04-19 embedded c166 with usart, iom-2 and hdlc support c165h c165h device version 1.3 cmos type package c165h p-tqfp-144 1 overview c165h is a new low cost member of the infineon communication controller family using low power cmos technology. the device combines the successful infineon c166 16-bit full-static core with four independent hdlc controllers, iom-2 interface and 3-kbyte of dual-port on-chip ram to a intelligent t erminal a dapter with h dlc support. c165h adresses all high feature isdn ta, intelligent nt or soho pbx designs, offering up to 18 mips along with legacy peripherals such as usart, sci and timers. c165h provides:  on-chip full-static c166 core supporting a 16- or 8-bit c16x family system running up to 36 mhz  isdn bri supporting data rates of 56 kbit/s, 64 kbit/s, 128 kbit/s and 144 kbit/s  iom-2/pcm interface ? terminal mode type interface to codec and s/u transceiver ? linecard mode type interface up to 8 iom-2 channels or 32 pcm channels ? 1536/786 khz and 1536 khz...4096 khz in 512 khz steps ? access to two intercommunication channels (ic1, ic2) ? access to two mon channels (mon0, mon1) ? access to two c/i channels (ci0, ci1) ? s/g access support  four on-chip independent full-duplex hdlc formatters ? 8 independent 8-byte fifos for each transmit and receive channel  usart interface with autobaud support (1,200 bit/s - 230,400 bit/s) ? at-command sensitive autobaud detection
c165h overview data sheet 12 2001-04-19 p r e l i m i n a r y - exc er p t - 1.1 key features c165h is a new low-cost member of the infineon communication controller family. the device has the following features:  c166 static core with peripherals including: ? full-static core up to 18 mips (@36 mhz) ? peripheral event controller (pec) for 8 independent dma channels ? 16 dynamically programmable priority-level interrupt system ? eight external interrupts ? up to 72 sw-configurative input/output (i/o) ports, some with interrupt capabilities ? 8-bit or 16-bit external data bus ? multiplexed or demultiplexed address/data bus ? up to 8-mbyte linear address space for code and data ? five programmable chip-select lines with wait-state generator logic ? on-chip 3,072-byte dual-port sram for user applications ? on-chip 1,024-byte special function register area ? on-chip pll with output clock signal ? five multimode general purpose timers ? on-chip programmable watchdog timer ? glueless interface to eprom, flash eprom and sram ? low-power management supporting idle-, power-down- and sleep-mode and additional cpu clock slow-down mode with mode control for each peripheral ? usart interface with auto baud rate detection up to 230.4 kbit/s ? usart baud rate generation in asynchronous mode up to 2.25 mbaud @ 36 mhz ? usart baud rate generation in synchronous mode up to 4.5 mbaud @ 36 mhz ? usart standard baud rates generation with very small deviation (230.4 kbaud < 0.01%, 460.8 kbaud < 0.15 %, 691.2 kbaud < 0.04 %, 921.6 kbaud < 0.15 % ) @ 36 mhz ? high speed serial synchronous channel interface (ssc) with alis-3.0 and ac97 compatibility up to 18 mbaud in ssc master mode and up to 9 mbaud in ssc slave mode @ 36 mhz  isdn terminal adapter features including: ? four independent full-duplex hdlc controllers ? iom-2/pcm interface supporting te, lt and pcm mode ? mon and ci1/ci2-handler ? two d-channels ? two b-channels supported ? concatenated 2b+d channel support ? two intercommunication channels ic1, ic2 ? d-channel access control to first iom channel-0 by s/g bit ? cda channel access to individual iom-2/pcm channels by sw
c165h overview data sheet 13 2001-04-19 p r e l i m i n a r y - exc er pt -  on-chip pll for cpu clock generation  external crystal and direct driven input clock frequency can vary between 4 and 20 mhz dependent on the cpu target clock frequency.  single and variable crystal clock input frequency  bootstrap loader support via usart interface  on-chip debug support (ocds)  jtag boundary scan test support according to ieee 1149.1  3.3 v single supply voltage  5 v (ttl-) tolerant i/os  c165h is available in 144-pin p-tqfp package  operating temperature range: -40 c to + 85 c.
c165h overview data sheet 14 2001-04-19 p r e l i m i n a r y - exc er p t - power management besides the basic power-save (power-reduction) modes idle mode and power down mode, the c165h offers a number of additional power management features, which can be selectively used for effective power reduction. refer to table 1 . note: peripherals management enables the user to control (via software) the clock of selected peripherals. refer to register syscon 3.  c165h power requirement in individual modes is described in dc characteristics, table 77 table 1 overview of power management modes mode description cpu wake-up running mode the system is fully operational. all clocks and peripherals are set and enabled, as determined by software. full power consumption. ---- slow down mode the cpu runs slower. the oscillator runs at a lower frequency; the clock is divided by a programmable factor (1...32). peripherals management is possible; incl. pll on/off. refer to register syscon 2. controlled by software. idle mode when the processor has no active tasks to perform, it enters idle mode by the idle command. all peripherals remain powered and clocked, however, peripherals management is possible. for detailed description see chapter 18.1, "idle mode".  any interrupt  reset sleep mode the program stops execution and turns off the clocks for:  almost the entire chip, but rtc, or  the entire chip. the whole clock system is stopped. refer to register syscon 1.  all enabled external interrupts nmi rtc timer (in asynchronous mode)  pec requests  asc interface  ssc interface power down mode the program stops execution (instruction pwrdn) and turns off the clocks for the cpu and for all peripherals; ports optionally.  reset
c165h overview data sheet 15 2001-04-19 p r e l i m i n a r y - exc er pt - 1.2 logic symbol the c165h logic symbol is shown in figure 1 below. figure 1 c165h logic symbol p-tqfp-144 c165h address/data bus iom-2/pcm general purpose i/o clock usart ssc/sci
c165h overview data sheet 16 2001-04-19 p r e l i m i n a r y - exc er p t - 1.3 pinning diagram figure 2 shows the pinning diagram of the c165h. figure 2 pinning diagram of the c165h unconnected p0h.1 p0h.0 p0l.7 p0l.6 p0l.5 c165h saf c165h - lf p-tqfp-144 108 73 104 100 96 92 88 84 80 76 144 109 140 136 132 128 124 120 116 112 37 72 40 44 48 52 56 60 64 68 14 8 12162024283236 144-t_c165h p0l.4 vss pol.3 pol.2 pol.1 p0l.0 vdd vss ale vdd vss p7.5 p7.4 p7.3 p7.2 p7.1 p7.0 vdd vss p4.6 p4.5 p4.4 p4.3 p4.2 p4.1 vdd wr / wrl ready ea rd unconnected unconnected tck tdi tdo tms vss vdd du dd dcl fsc clkmode vssa xtal1 xtal2 vdda p3.3 p3.5 p3.6 p3.7 vss vdd p3.8 p3.9 p3.10 p3.11 p3.12 p3.13 p3.15 p4.0 vss vdd unconnected brkin brkout p6.4 vss vdd p6.5 p6.6 p6.7 vss unconnected unconnected vdd p2.0 p2.1 p2.2 p2.3 vss vdd p2.4 p2.5 p2.6 p2.7 vss vdd test trst p1h.5 p1h.6 p1h.7 vss vdd p6.0 p6.1 p6.2 p6.3 rstin rstout nmi p0h.4 p0h.5 p0h.6 p0h.7 vss vdd p1l.0 p1l.1 p1l.2 p1l.3 vss vdd p1l.4 p1l.5 p1l.6 p1l.7 vss vdd p1h.0 p1h.1 p1h.2 p1h.3 p1h.4 vss vdd unconnected unconnected unconnected unconnected unconnected vss vdd p0h.2 p0h.3 vss vdd
c165h overview data sheet 17 2001-04-19 p r e l i m i n a r y - exc er pt - 1.4 typical applications 1.4.1 isdn nt and pbx applications c165h is designed to manage control message and data flow between the isdn s/u transceiver and a personal computer. data and message transfer is possible between either two of the following physical interfaces: iom-2 interface or local memory via 16-bit p-interface. since the iom-2 is transparently accessible, additional iom-2 devices such as codec, voice-encrypter or voice-codec devices can be accessed e.g. via the second iom-2 channel (ic1/ic2). figure 3 gives a general overview of the isdn nt/pbx application for c165h. figure 3 c165h in high feature intelligent network terminations note: in iom-2 lt mode for pbx systems, when additional external d-channel controllers are used, the drdy signal to control the access has to be connected to an external fast interrupt. within the terminal mode, this arbitration can be done with the stop/go bit on iom-2. s/t-interface u-interface intc-q2 nh u s pef81912 nh hv-slic hv-slic pots-interface slicofi-2 iom-2 v.24-interface v.24 flash sram c165 core ram ebc hdlc c165h pec xbus external bus
c165h pin descriptions data sheet 18 2001-04-19 p r e l i m i n a r y - exc er p t - 2 pin descriptions 2.1 c165h pin diagram figure 4 c165h pin configuration p-tqfp-144 c165h p0l(7:0) i/o or ad(7:0) p0h(7:0) i/o or ad(15:8) p1l(7:0) i/o or a(7:0) p1h(7:0) i/o or a(15:8) p4(6:0) i/o or a(22:16) rstin nmi rstout i/o or clkout wr/wrl ready ea rd ale exnint(7:0) p2(7:0) i/o or hlda i/o or hold i/o or cs(4:0) i/o or breq p6(4:0) p6(6) p6(5) p6(7) xtal1 xtal2 tdo tck tms tdi jtag port du dd iom-2/pcm port dcl fsc i/o or bhe or wrh p3(12) p3(15) p3(7:5,3) gpt1/2 port fast i/o or mrst i/o or mtsr ssc/sci port i/o or sclk serial p3(8) p3(9) p3(13) or i/o interrupts external i/o or txd i/o or rxd p3(10) p3(11) usart/asc port microcontroller bus p7(5:0) gpio port trst test clkmode brkout brkin ocds
c165h pin descriptions data sheet 19 2001-04-19 p r e l i m i n a r y - exc er pt - 2.2 c165h pin definitions and functions table 2 microprocessor bus and control signals pin no. symbol input (i) output (o) function 60-63, 66- 69, 70-71, 77-78, 81-84 port0: p0l0- p0l7, p0h0- p0h7 i/o port0 consists of the two 8-bit bidirectional i/o ports p0l and p0h. it is bitwise programmable for input or output via direction bits. for a pin configured as input, the output driver is put into high-impedance. in case of an external bus configuration, port0 serves as the address (a) and address/data (ad) bus in demultiplexed bus modes. demultiplexed bus modes: data path width: 8-bit 16-bit p0l0-p0l7: d0-d7 d0-d7 p0h0-p0h7: i/o d8-d15 multiplexed bus modes: data path width: 8-bit 16-bit p0l0-p0l7: ad0-ad7 ad0-ad7 p0h0-p0h7: a8-a15 ad8-ad15 87-90, 93- 96, 99-103, 109-111 port1: p1l0- p1l7, p1h0- p1h7 i/o port1 consists of the two 8-bit bidirectional i/o ports p1l and p1h. it is bitwise programmable for input or output via direction bits. for a pin configured as input, the output driver is put into high-impedance. port1 is used as the 16-bit address bus (a) in demultiplexed bus modes and also after switching from a demultiplexed bus mode to a multiplexed bus mode (see chapter 7.3).
c165h pin descriptions data sheet 20 2001-04-19 p r e l i m i n a r y - exc er p t - 31, 37-42 p4.0 - p4.6 i/o o o port4 is an 7-bit bidirectional i/o port. it is bit-wise programmable for input or output via direction bits. for a pin configured as input, the output driver is put into high-impedance state. in case of an external bus configuration, port4 can be used to output the segment address lines: p40 a16 least significant segment address line ... ... ... p4.6 a22 most significant segment address line 114 rstin i reset input with schmitt-trigger characteristics. a low level at this pin for a specified duration while the oscillator is running resets the device. an internal pull-up resistor permits power-on reset using only a capacitor connected to v ss . 115 rstout o internal reset indication output. this pin is set to a low level when the c165h is executing either a hardware-, software- or a watchdog timer reset. rstout remains low until the c165h has initialized itself. 116 nmi i non-maskable interrupt input. a high to low transition at this pin causes the cpu to vector to the nmi trap routine. when the pwrdn (power down) instruction is executed, the nmi pin must be low in order to force the cpu to go into power down mode. if nmi is high, when pwrdn is executed, the device will continue to run in normal mode. if not used, pin nmi should be pulled high externally. table 2 microprocessor bus and control signals (cont?d) pin no. symbol input (i) output (o) function
c165h pin descriptions data sheet 21 2001-04-19 p r e l i m i n a r y - exc er pt - 117-121, 124-126 p6.0- p6.7 o i/o o ... o i o o port6 is an 8-bit bidirectional i/o port. it is bit- wise programmable for input or output via direction bits. for a pin configured as input, the output driver is put into high-impedance state. port6 outputs can be configured as push/pull or open-drain drivers. p6.0 cs0 chip select 0 output ... ... ... p6.4 cs4 chip select 4 output p6.5 hold external master hold request input p6.6 hlda hold acknowledge output p6.7 breq bus request output 131-134, 137-140 p2.0- p2.7 i/o i i port2 is an 8-bit bidirectional i/o port. it is bit-wise programmable for input or output via direction bits. for a pin configured as input, the output driver is put into high-impedance state. port2 outputs can be configured as push/pull or open-drain drivers. p2.0 ex0in fast external interrupt 0 input p2.7 ex7in fast external interrupt 7 input 53 rd o external memory read strobe. rd is activated for every external instruction or data read access. 54 wr /wrl o external memory write strobe. in wr mode this pin is activated for every external data write access. in wrl mode this pin is activated for low byte data write accesses on a 16-bit bus, and for every data write access on an 8-bit bus. see wrcfg in register syscon for mode selection. 56 ale o address latch enable output. can be used for latching the address into external memory or an address latch in the multiplexed bus modes. table 2 microprocessor bus and control signals (cont?d) pin no. symbol input (i) output (o) function
c165h pin descriptions data sheet 22 2001-04-19 p r e l i m i n a r y - exc er p t - 55 ready i ready input. when the ready function is enabled, a high level at this pin during an external memory access will force the insertion of memory cycle time waitstates until the pin returns to an low level. 57 ea i external access enable pin. a low level at this pin during and after reset forces the cpu to begin instruction execution out of external memory. note: this pin must always be set to ?0?. 45-50 p7.0- p7.5 i/o port7 is an 6-bit bidirectional i/o port. it is bit-wise programmable for input or output via direction bits. for a pin configured as input, the output driver is put into high-impedance state. port7 outputs are push/pull drivers. p7.0 gpio0 ... p7.5 gpio5 table 2 microprocessor bus and control signals (cont?d) pin no. symbol input (i) output (o) function
c165h pin descriptions data sheet 23 2001-04-19 p r e l i m i n a r y - exc er pt - table 3 general purpose i/o and control signals pin no. symbol input (i) output (o) function 18-21, 24-30 p3.3, p3.5- p3.13, p3.15 i/o i/o i/o o i i i i/o i/o o i/o o o i/o o port3 is a 11-bit bidirectional i/o port. it is bit-wise programmable for input or output via direction bits. for a pin configured as input, the output driver is put into high-impedance state. port3 outputs can be configured as push/pull or open-drain drivers. the following port3 pins also serve for alternate functions: p3.3 t3out gpt1 timer t3 toggle latch output p3.5 t4in gpt1 timer t4 input for count/gate/reload/capture input for timer 3 t3eud input for timer 2 t2eud p3.6 t3in gpt1 timer t3 count/gate/ input p3.7 t2in gpt1 timer t2 input for count/gate/reload/capture p3.8 mrst ssc master-rec./slave- transmit i/o p3.9 mtsr ssc master-transmit/slave- rec. o/i p3.10 txd0 asc clock/data output (async./sync.) p3.11 rxd0 asc data input (async.) or i/o (sync.) p3.12 bhe external memory high byte enable signal wrh external memory high byte write strobe p3.13 sclk ssc master clock output/ slave clock input (cpu clock) p3.15 clkout system clock output (cpu clock)
c165h pin descriptions data sheet 24 2001-04-19 p r e l i m i n a r y - exc er p t - table 4 iom-2 interface signals pin no. symbol input (i) output (o) function 9 du i/o, od iom-2 data upstream signal pin. (from subscriber to network). for the pin configured as input, the output driver is put into high- impedance state. open-drain. 10 dd i/o, od iom-2 data downstream signal pin. (from network to subscriber). for the pin configured as input, the output driver is put into high- impedance state. open-drain. 11 dcl i iom-2 data clock signal input pin 12 fsc i iom-2 frame sync. clock signal input pin table 5 clock interface signals pin no. symbol input (i) output (o) function 15 xtal1 i external crystal input to the on-chip oscillator. clock input for direct driven clock without using an external crystal. function is determined by the clkmode pin. 16 xtal2 o output from the oscillator amplifier circuit. to clock the c165h from an external source, drive xtal1, while xtal2 leaving unconnected. minimum and maximum high/ low and rise/fall times specified in the ac characteristics must be observed. 13 clkmode i clock mode select pin. clkmode must be set to low if an external crystal is used. set to high signal enables the direct clock input path and switches the internal oscillator in power down mode.
c165h pin descriptions data sheet 25 2001-04-19 p r e l i m i n a r y - exc er pt - table 6 boundary scan / jtag / test interface signals/ocds pin no. symbol input (i) output (o) function 3 tck i boundary scan test clock input. there is no internal pull device implemented. during normal operation, it is recommended to connect tck to vss. 4 tdi i boundary scan test data input. an internal pull-up device is connected to tdi. during normal operation, tdi can be left open. 5 tdo o boundary scan test data output. during normal operation, the output tdo can be left open. 6 tms i boundary scan test mode select input, internal pull-up. 144 trst i boundary scan test reset. there is an internal pull-up device implemented. trst is low active, which means the boundary scan tap controller resets while trst = ?0?. for normal operation, trst can be connected to low signal (using ?0? signal or external pull-down device) to keep the tap controller in reset mode, or trst can be left open. in this case, the reset is performed using the tms/tck signals according to ieee 1149.1 in boundary scan test mode, trst can be left open, since the internal pull-up device pro- vides the necessary high signal. 143 test i test mode enable pin. high signal enables the chip internal test mode. note: in normal operation, test must be connected to vss (low signal) since no internal pull-down resistor is provided.
c165h pin descriptions data sheet 26 2001-04-19 p r e l i m i n a r y - exc er p t - 34 brkin i in ocds mode, a falling edge from high to low signal on brkin forces the system to stop. an internal pull-up resistor is provided. 35 brkout o in ocds mode, a falling edge on brkout indicates the trigger of a pre-selected ocds event. table 7 power/ground signals pin no. symbol input (i) output (o) function 8, 23, 33, 44, 52, 59, 65, 76, 80, 86, 92, 98, 105, 113, 123,130, 136, 142 vdd - digital supply voltage note: all pins must be connected to vdd. 7, 22, 32, 43, 51, 58, 64, 75, 79, 85, 91, 97, 104, 112, 122, 127, 135,141 vss - digital ground note: all pins must be connected to vss. table 6 boundary scan / jtag / test interface signals/ocds pin no. symbol input (i) output (o) function
c165h pin descriptions data sheet 27 2001-04-19 p r e l i m i n a r y - exc er pt - 17 vddax - analog supply voltage: vddax supplies the oscillator circuitry only, and is internal not connected to vdd in order to separate possible noise influence from the noise sensitive part. external, on board level, the vddax can be connected to the same power supply as the vdd. 14 vssax - analog ground vssax is connected to the oscillator circuitry gound only, in order to separate possible noise influence. external, on board level, the vssa can be connected to the same ground as the vss. table 8 unconnected pins pin no. symbol input (i) output (o) function 1, 2, 36, 72, 73, 74, 106, 107, 108 unconnected - these pins are unconnected - no function. reserved for future use. table 7 power/ground signals (cont?d) pin no. symbol input (i) output (o) function
c165h architectural overview data sheet 28 2001-04-19 p r e l i m i n a r y - exc er p t - 3 architectural overview the architecture of the c165h combines the advantages of both risc and cisc processors in a very well-balanced way. the sum of the features which are combined result in a high performance microcontroller, which is the right choice not only for today's applications, but also for future engineering challenges. the c165h not only integrates a powerful cpu core and a set of peripheral units into one chip, but also connects the units in a very efficient way. one of the four buses used concurrently on the c165h is the xbus, an internal representation of the external bus interface. this bus provides a standardized method of integrating application-specific peripherals to produce derivates of the standard c165h . figure 5 c165h functional block diagram cpu core p1 p2 p3 p4 p6 p7 p0 osc pll wdt jtag gpt1 asc gpt2 ocds iom-2 bus ssc ctl interrupt controller pec xbus module internal rom ram c165h
c165h architectural overview data sheet 29 2001-04-19 p r e l i m i n a r y - exc er pt - 3.1 basic cpu concepts and optimizations the main core of the cpu consists of a 4-stage instruction pipeline, a 16-bit arithmetic and logic unit (alu) and dedicated sfrs. additional hardware is provided for a separate multiply and divide unit, a bit-mask generator and a barrel shifter. figure 6 cpu block diagram to meet the demand for greater performance and flexibility, a number of areas has been optimized in the processor core. functional blocks in the cpu core are controlled by signals from the instruction decode logic. these are summarized below, and described in detail in the following sections: 1. high instruction bandwidth / fast execution 2. high function 8-bit and 16-bit arithmetic and logic unit 3. extended bit processing and peripheral control 4. high performance branch-, call-, and loop processing 5. consistent and optimized instruction formats 6. programmable multiple priority interrupt structure mcb02147 cpu sp stkov stkun instr. reg. instr. ptr. exec. unit 4-stage pipeline mdh mdl psw syscon context ptr. mul/div-hw r15 r0 general purpose registers bit-mask gen barrel - shifter alu (16-bit) data page ptr. code seg. ptr. internal ram r15 r0 rom 16 16 32 buscon 0 buscon 1 buscon 2 buscon 3 buscon 4 addrsel 4 addrsel 3 addrsel 2 addrsel 1
c165h architectural overview data sheet 30 2001-04-19 p r e l i m i n a r y - exc er p t - high instruction bandwidth / fast execution based on the hardware provisions, most of the c165h's instructions can be executed in just one machine cycle, which requires 55.6 ns at 36 mhz cpu clock. for example, shift and rotate instructions are always processed within one machine cycle, independent of the number of bits to be shifted. branch-, multiply- and divide instructions normally take more than one machine cycle. these instructions, however, have also been optimized. for example, branch instructions only require an additional machine cycle, when a branch is taken, and most branches taken in loops require no additional machine cycles at all, due to the so-called ?jump cache?. a 32-bit / 16-bit division takes 1 s, a 16-bit * 16-bit multiplication takes 0.5 s. the instruction cycle time has been dramatically reduced through the use of instruction pipelining. this technique allows the core cpu to process portions of multiple sequential instruction stages in parallel. the following four stage pipeline provides the optimum balancing for the cpu core: fetch: in this stage, an instruction is fetched from the ram or from the external memory, based on the current ip value. decode: in this stage, the previously fetched instruction is decoded and the required operands are fetched. execute: in this stage, the specified operation is performed on the previously fetched operands. write back: in this stage, the result is written to the specified location. if this technique were not used, each instruction would require four machine cycles. this increased performance allows a greater number of tasks and interrupts to be processed. instruction decoder instruction decoding is primarily generated from pla outputs based on the selected opcode. no microcode is used and each pipeline stage receives control signals staged in control registers from the decode stage plas. pipeline holds are primarily caused by wait states for external memory accesses and cause the holding of signals in the control registers. multiple-cycle instructions are performed through instruction injection and simple internal state machines which modify required control signals. high function 8-bit and 16-bit arithmetic and logic unit all standard arithmetic and logical operations are performed in a 16-bit alu. in addition, for byte operations, signals are provided from bits six and seven of the alu result to correctly set the condition flags. multiple precision arithmetic is provided through a 'carry-in' signal to the alu from previously calculated portions of the desired operation. most internal execution blocks have been optimized to perform operations on either 8-bit or 16-bit quantities. once the pipeline has been filled, one instruction is
c165h architectural overview data sheet 31 2001-04-19 p r e l i m i n a r y - exc er pt - completed per machine cycle, except for multiply and divide. an advanced booth algorithm has been incorporated to allow four bits to be multiplied and two bits to be divided per machine cycle. thus, these operations use two coupled 16-bit registers, mdl and mdh, and require four and nine machine cycles, respectively, to perform a 16-bit by 16-bit (or 32-bit by 16-bit) calculation plus one machine cycle to setup and adjust the operands and the result. even these longer multiply and divide instructions can be interrupted during their execution to allow for very fast interrupt response. instructions have also been provided to allow byte packing in memory while providing sign extension of bytes for word wide arithmetic operations. the internal bus structure also allows transfers of bytes or words to or from peripherals based on the peripheral requirements. a set of consistent flags is automatically updated in the psw after each arithmetic, logical, shift, or movement operation. these flags allow branching on specific conditions. support for both signed and unsigned arithmetic is provided through user-specifiable branch tests. these flags are also preserved automatically by the cpu upon entry into an interrupt or trap routine. all targets for branch calculations are also computed in the central alu. a 16-bit barrel shifter provides multiple bit shifts in a single cycle. rotates and arithmetic shifts are also supported. extended bit processing and peripheral control a large number of instructions has been dedicated to bit processing. these instructions provide efficient control and testing of peripherals while enhancing data manipulation. unlike other microcontrollers, these instructions provide direct access to two operands in the bit-addressable space without requiring to move them into temporary flags. the same logical instructions available for words and bytes are also supported for bits. this allows the user to compare and modify a control bit for a peripheral in one instruction. multiple bit shift instructions have been included to avoid long instruction streams of single bit shift operations. these are also performed in a single machine cycle. in addition, bit field instructions have been provided, which allow the modification of multiple bits from one operand in a single instruction. high performance branch-, call-, and loop processing due to the high percentage of branching in controller applications, branch instructions have been optimized to require one extra machine cycle only when a branch is taken. this is implemented by precalculating the target address while decoding the instruction. to decrease loop execution overhead, three enhancements have been provided:  the first solution provides single cycle branch execution after the first iteration of a loop. thus, only one machine cycle is lost during the execution of the entire loop. in loops which fall through upon completion, no machine cycles are lost when exiting the
c165h architectural overview data sheet 32 2001-04-19 p r e l i m i n a r y - exc er p t - loop. no special instructions are required to perform loops, and loops are automatically detected during execution of branch instructions.  the second loop enhancement allows the detection of the end of a table and avoids the use of two compare instructions embedded in loops. one simply places the lowest negative number at the end of the specific table, and specifies branching if neither this value nor the compared value have been found. otherwise the loop is terminated if either condition has been met. the terminating condition can then be tested.  the third loop enhancement provides a more flexible solution than the decrement and skip on zero instruction which is found in other microcontrollers. through the use of compare and increment or decrement instructions, the user can make comparisons to any value. this allows loop counters to cover any range. this is particularly advantageous in table searching. saving of system state is automatically performed on the internal system stack avoiding the use of instructions to preserve state upon entry and exit of interrupt or trap routines. call instructions push the value of the ip on the system stack, and require the same execution time as branch instructions. instructions have also been provided to support indirect branch and call instructions. this supports implementation of multiple case statement branching in assembler macros and high level languages. consistent and optimized instruction formats to obtain optimum performance in a pipelined design, an instruction set has been designed which incorporates concepts from reduced instruction set computing (risc). these concepts primarily allow fast decoding of the instructions and operands while reducing pipeline holds. these concepts, however, do not preclude the use of complex instructions, which are required by microcontroller users. the following goals were used to design the instruction set: 1. provide powerful instructions to perform operations which currently require sequences of instructions and are frequently used. avoid transfer into and out of temporary registers such as accumulators and carry bits. perform tasks in parallel such as saving state upon entry into interrupt routines or subroutines. 2. avoid complex encoding schemes by placing operands in consistent fields for each instruction. also avoid complex addressing modes which are not frequently used. this decreases the instruction decode time while also simplifying the development of compilers and assemblers. 3. provide most frequently used instructions with one-word instruction formats. all other instructions are placed into two-word formats. this allows all instructions to be placed on word boundaries, which alleviates the need for complex alignment hardware. it also has the benefit of increasing the range for relative branching instructions.
c165h architectural overview data sheet 33 2001-04-19 p r e l i m i n a r y - exc er pt - the high performance offered by the hardware implementation of the cpu can efficiently be utilized by a programmer via the highly functional c165h instruction set which includes the following instruction classes:  arithmetic instructions  logical instructions  boolean bit manipulation instructions  compare and loop control instructions  shift and rotate instructions  prioritize instruction  data movement instructions  system stack instructions  jump and call instructions  return instructions  system control instructions  miscellaneous instructions possible operand types are bits, bytes and words. specific instruction support the conversion (extension) of bytes to words. a variety of direct, indirect or immediate addressing modes are provided to specify the required operands. programmable multiple priority interrupt system the following enhancements have been included to allow processing of a large number of interrupt sources: 1. peripheral event controller (pec): this processor is used to off-load many interrupt requests from the cpu. it avoids the overhead of entering and exiting interrupt or trap routines by performing single-cycle interrupt-driven byte or word data transfers with an optional increment of either the pec source or the destination pointer. just one cycle is 'stolen' from the current cpu activity to perform a pec service. 2. multiple priority interrupt controller: this controller allows all interrupts to be placed at any specified priority. interrupts may also be grouped, which provides the user with the ability to prevent similar priority tasks from interrupting each other. for each of the possible interrupt sources there is a separate control register, which contains an interrupt request flag, an interrupt enable flag and an interrupt priority bitfield. once having been accepted by the cpu, an interrupt service can only be interrupted by a higher prioritized service request. for standard interrupt processing, each of the possible interrupt sources has a dedicated vector location. 3. multiple register banks: this feature allows the user to specify up to sixteen general purpose registers located anywhere in the internal ram. a single one-machine-cycle instruction allows to switch register banks from one task to another. 4. interruptable multiple cycle instructions: reduced interrupt latency is provided by allowing multiple-cycle instructions (multiply, divide) to be interruptable.
c165h architectural overview data sheet 34 2001-04-19 p r e l i m i n a r y - exc er p t - with an interrupt response time within a range from just 140 ns to 280 ns (in case of internal program execution), the c165h is capable of reacting very fast on non- deterministic events. its fast external interrupt inputs are sampled every 28 ns and allow to recognize even very short external signals. the c165h also provides an excellent mechanism to identify and to process exceptions or error conditions that arise during run-time, so called 'hardware traps'. hardware traps cause an immediate non-maskable system reaction which is similiar to a standard interrupt service (branching to a dedicated vector table location). the occurrence of a hardware trap is additionally signified by an individual bit in the trap flag register (tfr). except for another higher prioritized trap service being in progress, a hardware trap will interrupt any current program execution. in turn, hardware trap services can normally not be interrupted by standard or pec interrupts. software interrupts are supported by means of the 'trap' instruction in combination with an individual trap (interrupt) number. 3.2 on-chip system resources c165h controllers provide a number of powerful system resources designed around the cpu. the combination of cpu and these resources results in the high performance of the members of this controller family. peripheral event controller (pec) and interrupt control the peripheral event controller allows to respond to an interrupt request with a single data transfer (word or byte) which only consumes one instruction cycle and does not require to save and restore the machine status. each interrupt source is prioritized every machine cycle in the interrupt control block. if pec service is selected, a pec transfer is started. if cpu interrupt service is requested, the current cpu priority level stored in the psw register is tested to determine whether a higher priority interrupt is currently being serviced. when an interrupt is acknowledged, the current state of the machine is saved on the internal system stack and the cpu branches to the system specific vector for the peripheral. the pec contains a set of sfrs which store the count value and control bits for eight data transfer channels. in addition, the pec uses a dedicated area of ram which contains the source and destination addresses. the pec is controlled similar to any other peripheral through sfrs containing the desired configuration of each channel. an individual pec transfer counter is implicitly decremented for each pec service except forming in the continuous transfer mode. when this counter reaches zero, a standard interrupt is performed to the vector location related to the corresponding source. pec services are very well suited, for example, to move register contents to/from
c165h architectural overview data sheet 35 2001-04-19 p r e l i m i n a r y - exc er pt - a memory table. c165h has 8 pec channels each of which offers such fast interrupt- driven data transfer capabilities. memory areas the memory space of the c165h is configured in a von neumann architecture which means that code memory, data memory, registers and i/o ports are organized within the same linear address space which covers up to 8 mbytes. the entire memory space can be accessed bytewise or wordwise. particular portions of the on-chip memory have additionally been made directly bit addressable. a 16-bit wide internal ram (iram) provides fast access to general purpose registers (gprs), user data (variables) and system stack. the internal ram may also be used for code. a unique decoding scheme provides flexible user register banks in the internal memory while optimizing the remaining ram for user data. the size of the internal ram is 3 kbyte. the cpu disposes of an actual register context consisting of up to 16 wordwide and/or bytewide gprs, which are physically located within the on-chip ram area. a context pointer (cp) register determines the base address of the active register bank to be accessed by the cpu at a time. the number of register banks is only restricted by the available internal ram space. for easy parameter passing, a register bank may overlap others. a system stack of up to 1024 words is provided as a storage for temporary data. the system stack is also located within the on-chip ram area, and it is accessed by the cpu via the stack pointer (sp) register. two separate sfrs, stkov and stkun, are implicitly compared against the stack pointer value upon each stack access for the detection of a stack overflow or underflow. hardware detection of the selected memory space is placed at the internal memory decoders and allows the user to specify any address directly or indirectly and obtain the desired data without using temporary registers or special instructions. for special function registers 1024 bytes of the address space are reserved. the standard special function register area (sfr) uses 512 bytes, while the extended special function register area (esfr) uses the other 512 bytes. (e)sfrs are wordwide registers which are used for controlling and monitoring functions of the different on-chip units. unused (e)sfr addresses are reserved for future members of the c165h family with enhanced functionality. external bus interface in order to meet the needs of designs where more memory is required than is provided on chip, up to 8 mbytes of external ram and/or rom can be connected to the microcontroller via its external bus interface. the integrated external bus controller (ebc) allows to access external memory and/or peripheral resources in a very flexible
c165h architectural overview data sheet 36 2001-04-19 p r e l i m i n a r y - exc er p t - way. for up to five address areas the bus mode (multiplexed / demultiplexed), the data bus width (8-bit / 16-bit) and even the length of a bus cycle (waitstates, signal delays) can be selected independently. this allows to access a variety of memory and peripheral components directly and with maximum efficiency. if the device does not run in single chip mode, where no external memory is required, the ebc can control external accesses in one of the following four different external access modes: 16-/18-/20-/24-bit addresses, 16-bit data, demultiplexed 16-/18-/20-/24-bit addresses, 8-bit data, demultiplexed 16-/18-/20-/24-bit addresses, 16-bit data, multiplexed 16-/18-/20-/24-bit addresses, 8-bit data, multiplexed the demultiplexed bus modes use port1 for addresses and port0 for data input/ output. the multiplexed bus modes use port0 for both addresses and data input/ output. all modes use port 4 for the upper address lines (a16...) if selected. important timing characteristics of the external bus interface (waitstates, ale length and read/write delay) have been made programmable to allow the user the adaption of a wide range of different types of memories and/or peripherals. access to very slow memories or peripherals is supported via a particular 'ready' function. for applications which require less than 64 kbytes of address space, a non-segmented memory model can be selected, where all locations can be addressed by 16 bits, and thus port 4 is not needed as an output for the upper address bits (a22/a19/a17...a16), as is the case when using the segmented memory model. o n-chip xbus is an internal representation of the external bus and allows to access integrated application-specific peripherals/modules in the same way as external components. it provides a defined interface for these customized peripherals. 3.3 clock generation concept the on-chip clock generator provides the c165h with its basic clock signal that controls all activities of the controller hardware. its oscillator can either run with an external crystal and appropriate oscillator circuitry (see also recommendations in chapter ?dedicated pins?) or it can be driven by an external oscillator. the oscillator either directly feeds the external clock signal to the controller hardware (through buffers), divides the external clock frequency by 2 or 4, or feeds an on-chip phase locked loop (pll) which multiplies the input frequency by a selectable factor f . this resulting internal clock signal is also referred to as ?cpu clock?. two separated clock signals are generated for the cpu itself and the peripheral part of the chip. while the cpu clock is stopped during the idle mode, the peripheral clock keeps running. both clocks are switched off, when the power down mode is entered.
c165h architectural overview data sheet 37 2001-04-19 p r e l i m i n a r y - exc er pt - note: pin13 clkmode must be connected to low signal if an external crystal is used. pin cockmode connected to high signal enables the direct input path and switches the oscillator circuit in power down mode. the on-chip pll circuit allows operation of the c165h on a low frequency external clock while still providing maximum performance. the pll generates a cpu clock signal with 50% duty cycle. the pll also provides fail safe mechanisms which allow the detection of frequency deviations and the execution of emergency actions in case of an external clock failure. figure 7 shows the general clock generation concept of the c165h. the following constrains must be taken into account when considering the clock concept: 1. the maximum cpu clock frequency is 36 mhz (18 mips). 2. all ac and dc specifications described in chapter 23, "ac/dc characteristics" must be fulfilled. 3. the input frequency of the internal oscillator circuit is 4 mhz up to 20 mhz. this applies only, if an external crystal is used. 4. in direct drive mode, the internal oscillator circuit is bypassed. the clock input frequency range is 4 mhz up to 36 mhz. 5. the iom-2 module requires a minimum cpu clock of 5 times bitrate clock (bcl) on pin dcl. in pcm or lt mode the resulting clock is 5 * 2 mhz = 10 mhz. in te mode the minimum cpu clock frequency is 5 * 0.7 mhz 4 mhz.
c165h architectural overview data sheet 38 2001-04-19 p r e l i m i n a r y - exc er p t - figure 7 c165h general clock concept note: all supported clock modes for the c165h are shown in table 9 . because of the limited size of the register, there are not all combinations adjustable, which can be derived theoretical from figure 7 . % 2 % 2 phase detector charge pump loop filter vco common mode feedback cpu divider 1/(6,8,12,24) lock detection feedback divider 1/6 (288 mhz @ 8 mhz) pll unit clock unit mux mux mux mux clock control unit clkcfg pin 15 xtal1 pin 16 xtal2 pin 13 clkmode pin 30 clockout main cpu_clock osc (syscon: p0h7:5) f cpu = f in x f f osc owd control signals div1 div2 f xtal mux slow down divider syscon2.7 reload syscon2.10:14
c165h architectural overview data sheet 39 2001-04-19 p r e l i m i n a r y - exc er pt - table 9 c165h clock generation modes pll operation on power-up the pll provides a stable clock signal within ca. 1 ms after vdd has reached 3.3 v 10%, even if there is no external clock signal (in this case the pll will run on its basic frequency of 2...5 mhz). the pll starts synchronizing with the external clock signal as soon as it is available. within ca. 1 ms after stable oscillations of the external clock within the specified frequency range the pll will be synchronous with this clock at a frequency of f *f osc , ie. the pll locks to the external clock. note: if the c165h is required to operate on the desired cpu clock directly after reset make sure that rstin remains active until the pll has locked (ca. 1 ms). when pll operation is selected the cpu clock is a selectable multiple of the oscillator frequency, ie. the input frequency. the table above lists the possible selections. the pll constantly synchronizes to the external clock signal. due to the fact that the external frequency is 1/ f? th of the pll output frequency the output frequency may be slightly higher or lower than the desired frequency. this jitter is irrelevant for longer time periods. for short periods (1...4 cpu clock cycles) it remains below 4%. when the pll detects a missing input clock signal it generates an interrupt request. this warning interrupt indicates that the pll frequency is no more locked, ie. no more stable. this occurs when the input clock is unstable and especially when the input clock fails completely, eg. due to a broken crystal. in this case the synchronization mechanism will reduce the pll output frequency down to the pll?s basic frequency (2...5 mhz). the basic frequency is still generated and allows the cpu to execute emergency actions in case of a loss of the external clock. p0h.7-p0h.5 frequency divider activation 001 f xtal * 0.5 direct drive, d1 not active, d2 active, pll free running (2..5 mhz) note: the pll can be switched off completely by setting bit plldis = ?1? (syscon3.13, see page 429). 010 f xtal * 1.5 d1 not active, d2 not active, f = 1.5 011 f xtal * 1.0 direct drive, d1 not active, d2 not active, pll free running (2..5 mhz) note: the pll can be switched off completely by setting bit plldis = ?1? (syscon3.13, see page 429). 100 f xtal * 6.0 d1 not active, d2 not active, f = 6.0 101 f xtal * 1.125 d1 active, d2 active, f = 1.125 110 f xtal * 3.0 d1 not active, d2 not active, f = 3.0 111 f xtal * 4.5 d1 not active, d2 not active, f = 4.5, default mode 000 f xtal * 0.375 d1 active, d2 active, f = 0.375
c165h architectural overview data sheet 40 2001-04-19 p r e l i m i n a r y - exc er p t - prescaler operation when pins p0.15-13 (p0h.7-5) are equal ?001? during reset the cpu clock is derived from the internal oscillator (input clock signal) by a 2:1 prescaler (see table 9 ). the frequency of f cpu is half the frequency of f xtal and the high and low time of f cpu (ie. the duration of an individual tcl) is defined by the period of the input clock f xtal . the timings listed in the ?ac characteristics? of the data sheet that refer to tcls therefore can be calculated using the period of f xtal for any tcl. direct drive when pins p0.15-13 (p0h.7-5) equal ?011? during reset the clock system is directly driven from the internal oscillator with the input clock signal, ie. f osc = f cpu . the maximum input clock frequency depends on the clock signal?s duty cycle, because the minimum values for the clock phases (tcls) must be respected. oscillator watchdog the c165h provides an oscillator watchdog (owd) which monitors the clock signal generated by the on-chip oscillator (either with a crystal or via external clock drive) in prescaler or direct drive mode. for this operation the pll provides a clock signal which is used to supervise transitions on the oscillator clock. this pll clock is independent from the xtal1 clock. when the expected oscillator clock transitions are missing the owd activates the pll unlock / owd interrupt node and supplies the cpu with the pll clock signal. under these circumstances the pll will oscillate with its basic frequency. the owd?s interrupt output can be disabled by setting bit oscenbl = '0' (default after reset) in syscon register. in this case no oscillator watchdog interrupt request is generated and the cpu clock signal is derived from the oscillator clock in any case note: the cpu clock source is only switched back to the oscillator clock after a hardware reset. 3.4 on-chip peripheral blocks the c165h clearly separates peripherals from the core. this structure permits the maximum number of operations to be performed in parallel and allows peripherals to be added or deleted from family members without modifications to the core. each functional block processes data independently and communicates information over common buses. peripherals are controlled by data written to the respective special function registers (sfrs). these sfrs are located either within the standard sfr area (00?fe00 h ...00?ffff h ) or within the extended esfr area (00?f000 h ...00?f1ff h ). these built in peripherals either allow the cpu to interface with the external world, or provide functions on-chip that otherwise were to be added externally in the respective system.
c165h architectural overview data sheet 41 2001-04-19 p r e l i m i n a r y - exc er pt - c165h peripherals are:  two general purpose timer blocks (gpt1 and gpt2)  an asynchronous/synchronous serial interface (asc)  a high-speed synchronous serial interface (ssc)  an iom-2 interface (iom-2)  a watchdog timer (wdt)  seven i/o ports with a total of 72 i/o lines each peripheral also contains a set of special function registers (sfrs), which control the functionality of the peripheral and temporarily store intermediate data results. each peripheral has an associated set of status flags. individually selected clock signals are generated for each peripheral from binary multiples of the cpu clock. peripheral interfaces the on-chip peripherals generally have two different types of interfaces, an interface to the cpu and an interface to external hardware. communication between cpu and peripherals is performed through special function registers (sfrs) and interrupts. the sfrs serve as control/status and data registers for the peripherals. interrupt requests are generated by the peripherals based on specific events which occur during their operation (eg. operation complete, error, etc.). for interfacing with external hardware, specific pins of the parallel ports are used, when an input or output function has been selected for a peripheral. during this time, the port pins are controlled by the peripheral (when used as outputs) or by the external hardware which controls the peripheral (when used as inputs). this is called the 'alternate (input or output) function' of a port pin, in contrast to its function as a general purpose i/o pin. peripheral timing internal operation of cpu and peripherals is based on the cpu clock (f cpu ). the on-chip oscillator derives the cpu clock from the crystal or from the external clock signal. the clock signal which is gated to the peripherals is independent from the clock signal which feeds the cpu. during idle mode the cpu?s clock is stopped while the peripherals continue their operation. peripheral sfrs may be accessed by the cpu once per state. when an sfr is written to by software in the same state where it is also to be modified by the peripheral, the software write operation has priority. further details on peripheral timing are included in the specific sections about each peripheral. programming hints access to sfrs all sfrs reside in data page 3 of the memory space. the following addressing mechanisms allow to access the sfrs:
c165h architectural overview data sheet 42 2001-04-19 p r e l i m i n a r y - exc er p t -  indirect or direct addressing with 16-bit (mem) addresses it must be guaranteed that the used data page pointer (dpp0...dpp3) selects data page 3.  accesses via the peripheral event controller ( pec ) use the srcpx and dstpx pointers instead of the data page pointers  short 8-bit (reg) addresses to the standard sfr area do not use the data page pointers but directly access the registers within this 512 byte area.  short 8-bit (reg) addresses to the extended esfr area require switching to the 512 byte extended sfr area. this is done via the extension instructions extr, extp(r), exts(r). byte write operations to word wide sfrs via indirect or direct 16-bit (mem) addressing or byte transfers via the pec force zeros in the non-addressed byte. byte write operations via short 8-bit (reg) addressing can only access the low byte of an sfr and force zeros in the high byte. it is therefore recommended, to use the bit field instructions (bfldl and bfldh) to write to any number of bits in either byte of an sfr without disturbing the non-addressed byte and the unselected bits. reserved bits some of the bits which are contained in the c165h's sfrs are marked as 'reserved'. user software should never write '1's to reserved bits. these bits are currently not implemented and may be used in future products to invoke new functions. in this case, the active state for these functions will be '1', and the inactive state will be '0'. therefore writing only ?0?s to reserved locations provides portability of the current software to future devices. read accesses to reserved bits return ?0?s. parallel ports the c165h provides up to 72 i/o lines which are organized into seven input/output ports. all port lines are bit-addressable, and all input/output lines are individually (bit-wise) programmable as inputs or outputs via direction registers. the i/o ports are true bidirectional ports which are switched to high impedance state when configured as inputs. the output drivers of three i/o ports can be configured (pin by pin) for push/pull operation or open-drain operation via control registers. during the internal reset, all port pins are configured as inputs. all port lines have programmable alternate input or output functions associated with them. port0 and port1 may be used as address and data lines when accessing external memory, while port 4 outputs the additional segment address bits a22/a19/ a17...a16 in systems where segmentation is used to access more than 64 kbytes of memory. port 6 provides optional bus arbitration signals (breq , hlda , hold ) and chip select signals. port 2 accepts the fast external interrupt inputs. port 3 includes alternate functions of timers, serial interfaces, the optional bus control signal bhe and the system clock output (clkout). port 7 is used for general purpose i/os. all port lines that are not used for these alternate functions may be used as general purpose i/o lines.
c165h architectural overview data sheet 43 2001-04-19 p r e l i m i n a r y - exc er pt - serial channels serial communication with other microcontrollers, processors, terminals or external peripheral components is provided by two serial interfaces with different functionality, an asynchronous/synchronous serial channel (asc) and a high-speed synchronous serial channel (ssc). asc is upward compatible with the serial ports of the infineon 8-bit microcontroller families and supports full-duplex asynchronous communication at up to 2.25 mbaud and half-duplex synchronous communication at up to 4.5 mbaud @ 36 mhz cpu clock. a dedicated baud rate generator allows to set up all standard baud rates without oscillator tuning. for transmission, reception and error handling 4 separate interrupt vectors are provided. in asynchronous mode, 8- or 9-bit data frames are transmitted or received, preceded by a start bit and terminated by one or two stop bits. for multiprocessor communication, a mechanism to distinguish address from data bytes has been included (8-bit data plus wake up bit mode). in synchronous mode, the asc transmits or receives bytes (8 bits) synchronously to a shift clock which is generated by the asc. the asc always shifts the lsb first. a loop back option is available for testing purposes. a number of optional hardware error detection capabilities has been included to increase the reliability of data transfers. a parity bit can automatically be generated on transmission or be checked on reception. framing error detection allows to recognize data frames with missing stop bits. an overrun error will be generated, if the last character received has not been read out of the receive buffer register at the time the reception of a new character is complete. ssc supports full-duplex synchronous communication at up to 18 mbaud @ 36 mhz cpu clock in ssc master mode and up to 9 mbaud @ 36 mhz in ssc slave mode. it may be configured so it interfaces with serially linked peripheral components. a dedicated baud rate generator allows to set up all standard baud rates without oscillator tuning. for transmission, reception and error handling 3 separate interrupt vectors are provided. the ssc transmits or receives characters of 2...16 bits length synchronously to a shift clock which can be generated by the ssc (master mode) or by an external master (slave mode). the ssc can start shifting with the lsb or with the msb and allows the selection of shifting and latching clock edges as well as the clock polarity. a number of optional hardware error detection capabilities has been included to increase the reliability of data transfers. transmit and receive error supervise the correct handling of the data buffer. phase and baudrate error detect incorrect serial data. general purpose timer (gpt) unit the gpt units represent a very flexible multifunctional timer/counter structure which may be used for many different time related tasks such as event timing and counting, pulse width and duty cycle measurements, pulse generation, or pulse multiplication.
c165h architectural overview data sheet 44 2001-04-19 p r e l i m i n a r y - exc er p t - the five 16-bit timers are organized in two separate modules, gpt1 and gpt2. each timer in each module may operate independently in a number of different modes, or may be concatenated with another timer of the same module. each timer can be configured individually for one of three basic modes of operation, which are timer, gated timer, and counter mode. in timer mode the input clock for a timer is derived from the internal cpu clock divided by a programmable prescaler, while counter mode allows a timer to be clocked in reference to external events (via txin). pulse width or duty cycle measurement is supported in gated timer mode where the operation of a timer is controlled by the ?gate? level on its external input pin txin. the count direction (up/down) for each timer is programmable by software or may additionally be altered dynamically by an external signal (txeud) to facilitate eg. position tracking. the core timers t3 and t6 have output toggle latches (txotl) which change their state on each timer over-flow/underflow. the state of these latches may be output on port pins (txout) or may be used internally to concatenate the core timers with the respective auxiliary timers resulting in 32/33-bit timers/counters for measuring long time periods with high resolution. various reload or capture functions can be selected to reload timers or capture a timer?s contents triggered by an external signal or a selectable transition of toggle latch txotl. watchdog timer the watchdog timer represents one of the fail-safe mechanisms which have been implemented to prevent the controller from malfunctioning for longer periods of time. the watchdog timer is always enabled after a reset of the chip, and can only be disabled in the time interval until the einit (end of initialization) instruction has been executed. thus, the chip?s start-up procedure is always monitored. the software has to be designed to service the watchdog timer before it overflows. if, due to hardware or software related failures, the software fails to do so, the watchdog timer overflows and generates an internal hardware reset and pulls the rstout pin low in order to allow external hardware components to reset. the watchdog timer is a 16-bit timer, clocked with the cpu clock divided either by 2 or by 128. the high byte of the watchdog timer register can be set to a prespecified reload value (stored in wdtrel) in order to allow further variation of the monitored time interval. each time it is serviced by the application software, the high byte of the watchdog timer is reloaded. 3.5 protected bits the c165h provides a special mechanism to protect bits which can be modified by the on-chip hardware from being changed unintentionally by software accesses to related bits (see also chapter ?the central processing unit?).
c165h architectural overview data sheet 45 2001-04-19 p r e l i m i n a r y - exc er pt - the following bits are protected: = 33 protected bits in the c165h register bit name notes t2ic, t3ic, t4ic t2ir, t3ir, t4ir gpt1 timer interrupt request flags t5ic, t6ic t5ir, t6ir gpt2 timer interrupt request flags cric crir gpt2 caprel interrupt request flag t3con, t6con t3otl, t6otl gptx timer output toggle latches s0tic, s0tbic s0tir, s0tbir asc transmit(buffer) interrupt request flags s0ric, s0eic s0rir, s0eir asc receive/error interrupt request flags s0con s0ren asc receiver enable flag ssctic, sscric ssctir, sscrir ssc transmit/receive interrupt request flags ssceic ssceir ssc error interrupt request flag ssccon sscbsy ssc busy flag ssccon sscbe, sscpe ssc error flags ssccon sscre, sscte ssc error flags tfr tfr.15,14,13 class a trap flags tfr tfr.7,3,2,1,0 class b trap flags xpyic (y=3...0) xpyir (y=3...0) x-peripheral y interrupt request flag
c165h memory organization data sheet 46 2001-04-19 p r e l i m i n a r y - exc er p t - 4 memory organization the memory space of the c165h is configured in a ?von neumann? architecture. this means that code and data are accessed within the same linear address space. all of the physically separated memory areas, internal ram, the internal special function register areas (sfrs and esfrs), the address areas for integrated xbus peripherals and external memory are mapped into one common address space. the c165h provides a total addressable memory space of 8 mbytes. this address space is arranged as 128 segments of 64 kbytes each, and each segment is again subdivided into four data pages of 16 kbytes each (see figure 8 ). figure 8 memory areas and address space internal iram/sfr 00?0000 h 00?ffff h xram sfr area 00?ffff h 00?f000 h 00?e000 h 00?8000 h 00?e000 h esfr area 00?f200 h segment 0 00?e800 h area segment 1 segment 1 00?fe00 h 01?0000 h up to 3 kbyte iram xper/xram reserved for xpers 8 kbyte 2 kb xram extension 00?a000 h reserved for xram reserved for xflash compatible program reserved for memory
c165h memory organization data sheet 47 2001-04-19 p r e l i m i n a r y - exc er pt - bytes are stored at even or odd byte addresses. words are stored in ascending memory locations with the low byte at an even byte address being followed by the high byte at the next odd byte address. double words (code only) are stored in ascending memory locations as two subsequent words. single bits are always stored in the specified bit position at a word address. bit position 0 is the least significant bit of the byte at an even byte address, and bit position 15 is the most significant bit of the byte at the next odd byte address. bit addressing is supported for a part of the special function registers, a part of the internal ram and for the general purpose registers. figure 9 storage of words, byte and bits in a byte organized memory note: byte units forming a single word or a double word must always be stored within the same physical (internal, external, ram) and organizational (page, segment) memory area. mcd01996 15 14 8 0 6 7 h xxxx6 bits bits byte byte word (high byte) word (low byte) xxxx5 h xxxx4 h xxxx3 h xxxx2 h xxxx1 h xxxx0 h xxxxf h
c165h memory organization data sheet 48 2001-04-19 p r e l i m i n a r y - exc er p t - 4.1 internal ram and sfr area the ram/sfr area is located within data page 3 and provides access to the internal ram (iram, organized as x*16) and to two 512 byte blocks of special function registers (sfrs). the c165h provides 3 kbyte of iram, see figure 10 . the internal ram serves for several purposes:  system stack (programmable size)  general purpose register banks (gprs)  source and destination pointers for the peripheral event controller (pec)  variable and other data storage, or  code storage. figure 10 internal ram area and sfr areas system segment 0 64 kbyte area rom internal data page 1 data page 0 00 0000 h ? 00 4000 ? h external memory data page 3 data page 2 00 8000 ? h 00 00 00 00 e000 c000 ? ? h h f000 ffff ? ? h h ram/sfr area 4 kbyte esfr area f200 f000 mcd02233 00 ? 00 ? h h ram internal sfr area fe00 ffff 00 ram/sfr area ? 00 ? h h
c165h memory organization data sheet 49 2001-04-19 p r e l i m i n a r y - exc er pt - note: the upper 256 bytes of sfr area, esfr area and internal ram are bit- addressable (see shaded blocks in figure 10 ). code accesses are always made on even byte addresses. the highest possible code storage location in the internal ram is either 00?fdfe h for single word instructions or 00?fdfc h for double word instructions. the respective location must contain a branch instruction (unconditional), because sequential boundary crossing from internal ram to the sfr area is not supported and causes erroneous results. any word and byte data in the internal ram can be accessed via indirect or long 16-bit addressing modes, if the selected dpp register points to data page 3. any word data access is made on an even byte address. the highest possible word data storage location in the internal ram is 00?fdfe h . for pec data transfers, the internal ram can be accessed independent of the contents of the dpp registers via the pec source and destination pointers. the upper 256 byte of the internal ram (00?fd00 h through 00?fdff h ) and the gprs of the current bank are provided for single bit storage, and thus they are bit addressable. system stack the system stack may be defined within the internal ram. the size of the system stack is controlled by bitfield stksz in register syscon (see table below). for all system stack operations the on-chip ram is accessed via the stack pointer (sp) register. the stack grows downward from higher towards lower ram address locations. only word accesses are supported to the system stack. a stack overflow (stkov) and a stack underflow (stkun) register are provided to control the lower and upper limits of the selected stack area. these two stack boundary registers can be used not only for protection against data destruction, but also allow to implement a circular stack with hardware supported system stack flushing and filling (except for option ?111?). the technique of implementing this circular stack is described in chapter ?system programming?. stack size (words) internal ram addresses (words) 0 0 0 b 256 00 ? fbfe h ...00 ? fa00 h (default after reset) 0 0 1 b 128 00 ? fbfe h ...00 ? fb00 h 0 1 0 b 64 00 ? fbfe h ...00 ? fb80 h 0 1 1 b 32 00 ? fbfe h ...00 ? fbc0 h 1 0 0 b 512 00 ? fbfe h ...00 ? f800 h 1 0 1 b --- reserved. do not use this combination. 1 1 0 b --- reserved. do not use this combination. 1 1 1 b 1024 00 ? fdfe h ...00 ? f600 h (note: no circular stack)
c165h memory organization data sheet 50 2001-04-19 p r e l i m i n a r y - exc er p t - general purpose registers the general purpose registers (gprs) use a block of 16 consecutive words within the internal ram. the context pointer (cp) register determines the base address of the currently active register bank. this register bank may consist of up to 16 word gprs (r0, r1, ..., r15) and/or of up to 16 byte gprs (rl0, rh0, ..., rl7, rh7). the sixteen byte gprs are mapped onto the first eight word gprs (see table below). in contrast to the system stack, a register bank grows from lower towards higher address locations and occupies a maximum space of 32 byte. the gprs are accessed via short 2-, 4- or 8-bit addressing modes using the context pointer (cp) register as base address (independent of the current dpp register contents). additionally, each bit in the currently active register bank can be accessed individually. mapping of general purpose registers to ram addresses c165h supports fast register bank (context) switching. multiple register banks can physically exist within the internal ram at the same time. only the register bank selected by the context pointer register (cp) is active at a given time, however. selecting a new active register bank is simply done by updating the cp register. a particular switch context (scxt) instruction performs register bank switching and an automatic saving of the previous context. the number of implemented register banks (arbitrary sizes) is only limited by the size of the available internal ram. internal ram address byte registers word register + 1e h --- r15 + 1c h --- r14 + 1a h --- r13 + 18 h --- r12 + 16 h --- r11 + 14 h --- r10 + 12 h --- r9 + 10 h --- r8 + 0e h rh7 rl7 r7 + 0c h rh6 rl6 r6 + 0a h rh5 rl5 r5 + 08 h rh4 rl4 r4 + 06 h rh3 rl3 r3 + 04 h rh2 rl2 r2 + 02 h rh1 rl1 r1 + 00 h rh0 rl0 r0
c165h memory organization data sheet 51 2001-04-19 p r e l i m i n a r y - exc er pt - details on using, switching and overlapping register banks are described in chapter ?system programming?. pec source and destination pointers the 16 word locations in the internal ram from 00?fce0 h to 00?fcfe h (just below the bit-addressable section) are provided as source and destination address pointers for data transfers on the eight pec channels. each channel uses a pair of pointers stored in two subsequent word locations with the source pointer (srcpx) on the lower and the destination pointer (dstpx) on the higher word address (x = 7...0). figure 11 location of the pec pointers whenever a pec data transfer is performed, the pair of source and destination pointers, which is selected by the specified pec channel number, is accessed independent of the current dpp register contents and also the locations referred to by these pointers are accessed independent of the current dpp register contents. if a pec channel is not used, the corresponding pointer locations area available and can be used for word or byte data storage. for more details about the use of the source and destination pointers for pec data transfers see section ?interrupt and trap functions?. 00 ? fce2 00 ? fce0 h h srcp0 dstp0 00 ? f5fe 00 ? f600 mcd03903 h h destination 00 ? fcfc pointers and h pec source srcp7 00 ? fcfe h dstp7 internal 00 ? fce0 00 ? fcde ram h h 00 ? fcfe 00 ? fd00 h h
c165h memory organization data sheet 52 2001-04-19 p r e l i m i n a r y - exc er p t - special function registers the functions of the cpu, the bus interface, the i/o ports and the on-chip peripherals of the c165h are controlled via a number of so-called special function registers (sfrs). these sfrs are arranged within two areas of 512 byte size each. the first register block, the sfr area, is located in the 512 bytes above the internal ram (00?ffff h ...00?fe00 h ), the second register block, the extended sfr (esfr) area, is located in the 512 bytes below the internal ram (00?f1ff h ...00?f000 h ). special function registers can be addressed via indirect and long 16-bit addressing modes. using an 8-bit offset together with an implicit base address allows to address word sfrs and their respective low bytes. however, this does not work for the respective high bytes! note: writing to any byte of an sfr causes the non-addressed complementary byte to be cleared! the upper half of each register block is bit-addressable, so the respective control/status bits can directly be modified or checked using bit addressing. when accessing registers in the esfr area using 8-bit addresses or direct bit addressing, an extend register (extr) instruction is required before, to switch the short addressing mechanism from the standard sfr area to the extended sfr area. this is not required for 16-bit and indirect addresses. the gprs r15...r0 are duplicated, ie. they are accessible within both register blocks via short 2-, 4- or 8-bit addresses without switching. esfr_switch_example: extr #4 ;switch to esfr area for next 4 instr. mov odp2, #data16 ;odp2 uses 8-bit reg addressing bfldl dp6, #mask, #data8 ;bit addressing for bit fields bset dp1h.7 ;bit addressing for single bits mov t8rel, r1 ;t8rel uses 16-bit mem address, ;r1 is duplicated into the esfr space ;(extr is not required for this access) ;---- ;------------------- ;the scope of the extr #4 instruction... ;...ends here! mov t8rel, r1 ;t8rel uses 16-bit mem address, ;r1 is accessed via the sfr space
c165h memory organization data sheet 53 2001-04-19 p r e l i m i n a r y - exc er pt - in order to minimize the use of the extr instructions the esfr area mostly holds registers which are mainly required for initialization and mode selection. registers that need to be accessed frequently are allocated to the standard sfr area, wherever possible. note: the tools are equipped to monitor accesses to the esfr area and will automatically insert extr instructions, or issue a warning in case of missing or excessive extr instructions. 4.2 external memory space the c165h is capable of using an address space of up to 8 mbyte. only parts of this address space are occupied by internal memory areas. all addresses which are not used for on-chip memory (ram) or for registers may reference external memory locations. this external memory is accessed via the c165h?s external bus interface. four memory bank sizes are supported:  non-segmented mode: 64 kbyte with a15...a0 on port0 or port1  2-bit segmented mode: 256 kbyte with a17...a16 on port 4 and a15...a0 on port0 or port1  4-bit segmented mode: 1 mbyte with a19...a16 on port 4 and a15...a0 on port0 or port1  8-bit segmented mode: 8 mbyte with a22...a16 on port 4 and a15...a0 on port0 or port1 each bank can be directly addressed via the address bus, while the programmable chip select signals can be used to select various memory banks. the c165h also supports four different bus types :  multiplexed 16-bit buswith address and data on port0 (default after reset)  multiplexed 8-bit buswith address and data on port0/p0l  demultiplexed 16-bit buswith address on port1 and data on port0  demultiplexed 8-bit buswith address on port1 and data on p0l memory model and bus mode are selected during reset by pin ea and port0 pins. for further details about the external bus configuration and control please refer to chapter "the external bus interface". external word and byte data can only be accessed via indirect or long 16-bit addressing modes using one of the four dpp registers. there is no short addressing mode for external operands. any word data access is made to an even byte address. for pec data transfers the external memory can be accessed independent of the contents of the dpp registers via the pec source and destination pointers.
c165h memory organization data sheet 54 2001-04-19 p r e l i m i n a r y - exc er p t - the external memory is not provided for single bit storage and therefore it is not bit addressable. 4.3 crossing memory boundaries the address space of the c165h is implicitly divided into equally sized blocks of different granularity and into logical memory areas. crossing the boundaries between these blocks (code or data) or areas requires special attention to ensure that the controller executes the desired operations. memory areas are partitions of the address space that represent different kinds of memory (if provided at all). these memory areas are the internal ram/sfr area, the on- chip x-peripherals and the external memory. accessing subsequent data locations that belong to different memory areas is no problem. however, when executing code , the different memory areas must be switched explicitly via branch instructions. sequential boundary crossing is not supported and leads to erroneous results. note: changing from the external memory area to the internal ram/sfr area takes place within segment 0. segments are contiguous blocks of 64 kbyte each. they are referenced via the code segment pointer csp for code fetches and via an explicit segment number for data accesses overriding the standard dpp scheme. during code fetching segments are not changed automatically, but rather must be switched explicitly. the instructions jmps, calls and rets will do this. in larger sequential programs make sure that the highest used code location of a segment contains an unconditional branch instruction to the respective following segment, to prevent the prefetcher from trying to leave the current segment. data pages are contiguous blocks of 16 kbyte each. they are referenced via the data page pointers dpp3...0 and via an explicit data page number for data accesses overriding the standard dpp scheme. each dpp register can select one of the possible 1024 data pages. the dpp register that is used for the current access is selected via the two upper bits of the 16-bit data address. subsequent 16-bit data addresses that cross the 16 kbyte data page boundaries therefore will use different data page pointers, while the physical locations need not be subsequent within memory.
c165h central processor unit data sheet 55 2001-04-19 p r e l i m i n a r y - exc er pt - 5 central processor unit basic tasks of the cpu are to fetch and decode instructions, to supply operands for the arithmetic and logic unit (alu), to perform operations on these operands in the alu, and to store the previously calculated results. as the cpu is the main engine of the c165h controller, it is also affected by certain actions of the peripheral subsystem. since a four stage pipeline is implemented in the c165h, up to four instructions can be processed in parallel. most instructions of the c165h are executed in one machine cycle (2 cpu clock cycles) due to this parallelism. this chapter describes how the pipeline works for sequential and branch instructions in general, and which hardware provisions have been made to speed the execution of jump instructions in particular. the general instruction timing is described including standard and exceptional timing. while internal memory accesses are normally performed by the cpu itself, external peripheral or memory accesses are performed by a particular on-chip external bus controller (ebc), which is automatically invoked by the cpu whenever a code or data address refers to the external address space. if possible, the cpu continues operating while an external memory access is in progress. if external data are required but are not yet available, or if a new external memory access is requested by the cpu, before a previous access has been completed, the cpu will be held by the ebc until the request can be satisfied. the ebc is described in a dedicated chapter. figure 12 cpu block diagram mcb02147 cpu sp stkov stkun instr. reg. instr. ptr. exec. unit 4-stage pipeline mdh mdl psw syscon context ptr. mul/div-hw r15 r0 general purpose registers bit-mask gen barrel - shifter alu (16-bit) data page ptr. code seg. ptr. internal ram r15 r0 rom 16 16 32 buscon 0 buscon 1 buscon 2 buscon 3 buscon 4 addrsel 4 addrsel 3 addrsel 2 addrsel 1
c165h central processor unit data sheet 56 2001-04-19 p r e l i m i n a r y - exc er p t - the on-chip peripheral units of the c165h work nearly independent of the cpu with a separate clock generator. data and control information is interchanged between the cpu and these peripherals via special function registers (sfrs). whenever peripherals need a non-deterministic cpu action, an on-chip interrupt controller compares all pending peripheral service requests against each other and prioritizes one of them. if the priority of the current cpu operation is lower than the priority of the selected peripheral request, an interrupt will occur. basically, there are two types of interrupt processing:  standard interrupt processing forces the cpu to save the current program status and the return address on the stack before branching to the interrupt vector jump table.  pec interrupt processing steals just one machine cycle from the current cpu activity to perform a single data transfer via the on-chip peripheral event controller (pec). system errors detected during program execution (socalled hardware traps) or an external non-maskable interrupt are also processed as standard interrupts with a very high priority. in contrast to other on-chip peripherals, there is a closer conjunction between the watchdog timer and the cpu. if enabled, the watchdog timer expects to be serviced by the cpu within a programmable period of time, otherwise it will reset the chip. thus, the watchdog timer is able to prevent the cpu from going totally astray when executing erroneous code. after reset, the watchdog timer starts counting automatically, but it can be disabled via software, if desired. beside its normal operation there are the following particular cpu states:  reset state: any reset (hardware, software, watchdog) forces the cpu into a predefined active state.  idle state: the clock signal to the cpu itself is switched off, while the clocks for the on-chip peripherals keep running.  power down state: all of the on-chip clocks are switched off. a transition into an active cpu state is forced by an interrupt (if being idle) or by a reset (if being in power down mode). the idle, power down and reset states can be entered by particular c165h system control instructions. a set of special function registers is dedicated to the functions of the cpu core:  general system configuration: syscon (rp0h)  cpu status indication and control: psw  code access control: ip, csp  data paging control: dpp0, dpp1, dpp2, dpp3  gprs access control: cp  system stack access control: sp, stkun, stkov
c165h central processor unit data sheet 57 2001-04-19 p r e l i m i n a r y - exc er pt -  multiply and divide support: mdl, mdh, mdc  alu constants support: zeros, ones 5.1 instruction pipelining the instruction pipeline of the c165h partitiones instruction processing into four stages of which each one has its individual task: 1st ?>fetch: in this stage the instruction selected by the instruction pointer (ip) and the code segment pointer (csp) is fetched from either the internal ram, or external memory. 2nd ?>decode: in this stage the instructions are decoded and, if required, the operand addresses are calculated and the respective operands are fetched. for all instructions, which implicitly access the system stack, the sp register is either decremented or incremented, as specified. for branch instructions the instruction pointer and the code segment pointer are updated with the desired branch target address (provided that the branch is taken). 3rd ?>execute: in this stage an operation is performed on the previously fetched operands in the alu. additionally, the condition flags in the psw register are updated as specified by the instruction. all explicit writes to the sfr memory space and all auto-increment or auto- decrement writes to gprs used as indirect address pointers are performed during the execute stage of an instruction, too. 4th ?>write back: in this stage all external operands and the remaining operands within the internal ram space are written back. a particularity of the c165h are the so-called injected instructions. these injected instructions are generated internally by the machine to provide the time needed to process instructions, which cannot be processed within one machine cycle. they are automatically injected into the decode stage of the pipeline, and then they pass through the remaining stages like every standard instruction. program interrupts are performed by means of injected instructions, too. although these internally injected instructions will not be noticed in reality, they are introduced here to ease the explanation of the pipeline in the following. sequential instruction processing each single instruction has to pass through each of the four pipeline stages regardless of whether all possible stage operations are really performed or not. since passing through one pipeline stage takes at least one machine cycle, any isolated instruction takes at least four machine cycles to be completed. pipelining, however, allows parallel (ie. simultaneous) processing of up to four instructions. thus, most of the instructions
c165h central processor unit data sheet 58 2001-04-19 p r e l i m i n a r y - exc er p t - seem to be processed during one machine cycle as soon as the pipeline has been filled once after reset (see figure below). instruction pipelining increases the average instruction throughput considered over a certain period of time. in the following, any execution time specification of an instruction always refers to the average execution time due to pipelined parallel instruction processing. figure 13 sequential instruction pipelining standard branch instruction processing instruction pipelining helps to speed sequential program processing. in the case that a branch is taken, the instruction which has already been fetched providently is mostly not the instruction which must be decoded next. thus, at least one additional machine cycle is normally required to fetch the branch target instruction. this extra machine cycle is provided by means of an injected instruction (see figure 14 ). figure 14 standard branch instruction pipelining 1 machine cycle fetch i 2 i 1 i 3 i 2 i 1 i 4 i 3 i 2 i 1 i 6 i 5 i 4 i 3 i 5 i 4 i 3 i 2 i 1 decode execute writeback time 1 machine cycle fetch i n+2 branch i n . . . i target (i inject ) branch i n i target+1 i target (i inject ) branch i target+3 i target+2 i target+1 i target i target+2 i target+1 i target (i inject ) branch i n . . . . . . decode execute writeback time injection
c165h central processor unit data sheet 59 2001-04-19 p r e l i m i n a r y - exc er pt - if a conditional branch is not taken, there is no deviation from the sequential program flow, and thus no extra time is required. in this case the instruction after the branch instruction will enter the decode stage of the pipeline at the beginning of the next machine cycle after decode of the conditional branch instruction. cache jump instruction processing the c165h incorporates a jump cache to optimize conditional jumps, which are processed repeatedly within a loop. whenever a jump on cache is taken, the extra time to fetch the branch target instruction can be saved and thus the corresponding cache jump instruction in most cases takes only one machine cycle. this performance is achieved by the following mechanism: whenever a cache jump instruction passes through the decode stage of the pipeline for the first time (and provided that the jump condition is met), the jump target instruction is fetched as usual, causing a time delay of one machine cycle. in contrast to standard branch instructions, however, the target instruction of a cache jump instruction (jmpa, jmpr, jb, jbc, jnb, jnbs) is additionally stored in the cache after having been fetched. after each repeatedly following execution of the same cache jump instruction, the jump target instruction is not fetched from progam memory but taken from the cache and immediatly injected into the decode stage of the pipeline (see figure 15 ). a time saving jump on cache is always taken after the second and any further occurrence of the same cache jump instruction, unless an instruction which, has the fundamental capability of changing the csp register contents (jmps, calls, rets, trap, reti), or any standard interrupt has been processed during the period of time between two following occurrences of the same cache jump instruction. figure 15 cache jump instruction pipelining i n+2 cache jmp i n . . . i target+1 i target cache jmp i n i target+2 i target+1 i target cache jmp i n+2 cache jmp i n . . . i target (i inject ) cache jmp i n i target+1 i target (i inject ) cache jmp 1 machine cycle fetch decode execute writeback 1st loop iteration injection injection of cached target instruction repeated loop iteration
c165h central processor unit data sheet 60 2001-04-19 p r e l i m i n a r y - exc er p t - particular pipeline effects since up to four different instructions are processed simultaneously, additional hardware has been spent in the c165h to consider all causal dependencies which may exist on instructions in different pipeline stages without a loss of performance. this extra hardware (ie. for 'forwarding' operand read and write values) resolves most of the possible conflicts (eg. multiple usage of buses) in a time optimized way and thus avoids that the pipeline becomes noticeable for the user in most cases. however, there are some very rare cases, where the circumstance that the c165h is a pipelined machine requires attention by the programmer. in these cases the delays caused by pipeline conflicts can be used for other instructions in order to optimize performance. ? context pointer updating an instruction, which calculates a physical gpr operand address via the cp register, is mostly not capable of using a new cp value, which is to be updated by an immediately preceding instruction. thus, to make sure that the new cp value is used, at least one instruction must be inserted between a cp-changing and a subsequent gpr-using instruction, as shown in the following example: i n : scxt cp, #0fc00h ; select a new context i n+1 : .... ; must not be an instruction using a gpr i n+2 : mov r0, #datax ; write to gpr 0 in the new context ? data page pointer updating an instruction, which calculates a physical operand address via a particular dppn (n=0 to 3) register, is mostly not capable of using a new dppn register value, which is to be updated by an immediately preceding instruction. thus, to make sure that the new dppn register value is used, at least one instruction must be inserted between a dppn- changing instruction and a subsequent instruction which implicitly uses dppn via a long or indirect addressing mode, as shown in the following example: i n : mov dpp0, #4 ; select data page 4 via dpp0 i n+1 : .... ; must not be an instruction using dpp0 i n+2 : mov dpp0:0000h, r1 ; move contents of r1 to address location 01 ? 0000 h ; (in data page 4) supposed segmentation is enabled ? explicit stack pointer updating none of the ret, reti, rets, retp or pop instructions is capable of correctly using a new sp register value, which is to be updated by an immediately preceding instruction. thus, in order to use the new sp register value without erroneously performed stack accesses, at least one instruction must be inserted between an explicitly sp-writing and any subsequent of the just mentioned implicitly sp-using instructions, as shown in the following example: i n : mov sp, #0fa40h ; select a new top of stack
c165h central processor unit data sheet 61 2001-04-19 p r e l i m i n a r y - exc er pt - i n+1 : .... ; must not be an instruction popping operands ; from the system stack i n+2 : pop r0 ; pop word value from new top of stack into r0 note: conflicts with instructions writing to the stack (push, call, scxt) are solved internally by the cpu logic. ? external memory access sequences the effect described here will only become noticeable, when watching the external memory access sequences on the external bus (eg. by means of a logic analyzer). different pipeline stages can simultaneously put a request on the external bus controller (ebc). the sequence of instructions processed by the cpu may diverge from the sequence of the corresponding external memory accesses performed by the ebc, due to the predefined priority of external memory accesses: 1st write data 2nd fetch code 3rd read data. ? controlling interrupts software modifications (implicit or explicit) of the psw are done in the execute phase of the respective instructions. in order to maintain fast interrupt responses, however, the current interrupt prioritization round does not consider these changes, ie. an interrupt request may be acknowledged after the instruction that disables interrupts via ien or ilvl or after the following instructions. timecritical instruction sequences therefore should not begin directly after the instruction disabling interrupts, as shown in the following example: int_off: bclr ien ; globally disable interrupts i n-1 ; non-critical instruction crit_1st: i n ; begin of uninterruptable critical sequence . . . crit_last: i n+x ; end of uninterruptable critical sequence int_on: bset ien ; globally re-enable interrupts note: the described delay of 1 instruction also applies for enabling the interrupts system ie. no interrupt requests are acknowledged until the instruction following the enabling instruction. ? initialization of port pins modifications of the direction of port pins (input or output) become effective only after the instruction following the modifying instruction. as bit instructions (bset, bclr) use internal read-modify-write sequences accessing the whole port, instructions modifying
c165h central processor unit data sheet 62 2001-04-19 p r e l i m i n a r y - exc er p t - the port direction should be followed by an instruction that does not access the same port (see example below). wrong: bset dp3.13 ; change direction of p3.13 to output bset p3.5 ; p3.13 is still input, the rd-mod-wr reads pin p3.13 right: bset dp3.13 ; change direction of p3.13 to output nop ; any instruction not accessing port 3 bset p3.5 ; p3.13 is now output, ; the rd-mod-wr reads the p3.13 output latch ? changing the system configuration the instruction following an instruction that changes the system configuration via register syscon (eg. segmentation, stack size) cannot use the new resources (eg. stack). in these cases an instruction that does not access these resources should be inserted. ? buscon/addrsel the instruction following an instruction that changes the properties of an external address area cannot access operands within the new area. in these cases an instruction that does not access this address area should be inserted. code accesses to the new address area should be made after an absolute branch to this area. note: as a rule, instructions that change external bus properties should not be executed from the respective external memory area. ? timing instruction pipelining reduces the average instruction processing time in a wide scale (from four to one machine cycles, mostly). however, there are some rare cases, where a particular pipeline situation causes the processing time for a single instruction to be extended either by a half or by one machine cycle. although this additional time represents only a tiny part of the total program execution time, it might be of interest to avoid these pipeline-caused time delays in time critical program modules. besides a general execution time description, the following section provides some hints on how to optimize time-critical program parts with regard to such pipeline-caused timing particularities.
c165h central processor unit data sheet 63 2001-04-19 p r e l i m i n a r y - exc er pt - 5.2 bit-handling and bit-protection the c165h provides several mechanisms to manipulate bits. these mechanisms either manipulate software flags within the internal ram, control on-chip peripherals via control bits in their respective sfrs or control i/o functions via port pins. the instructions bset, bclr, band, bor, bxor, bmov, bmovn explicitly set or clear specific bits. the instructions bfldl and bfldh allow to manipulate up to 8 bits of a specific byte at one time. the instructions jbc and jnbs implicitly clear or set the specified bit when the jump is taken. the instructions jb and jnb (also conditional jump instructions that refer to flags) evaluate the specified bit to determine if the jump is to be taken. note: bit operations on undefined bit locations will always read a bit value of ?0?, while the write access will not effect the respective bit location. all instructions that manipulate single bits or bit groups internally use a read-modify-write sequence that accesses the whole word, which contains the specified bit(s). this method has several consequences:  bits can only be modified within the internal address areas, ie. internal ram and sfrs. external locations cannot be used with bit instructions. the upper 256 bytes of the sfr area, the esfr area and the internal ram are bit- addressable (see chapter ?memory organization?), ie. those register bits located within the respective sections can be directly manipulated using bit instructions. the other sfrs must be accessed byte/word wise. note: all gprs are bit-addressable independent of the allocation of the register bank via the context pointer cp. even gprs which are allocated to not bit-addressable ram locations provide this feature.  the read-modify-write approach may be critical with hardware-effected bits. in these cases the hardware may change specific bits while the read-modify-write operation is in progress, where the writeback would overwrite the new bit value generated by the hardware. the solution is either the implemented hardware protection (see below) or realized through special programming (see ?particular pipeline effects?). protected bits are not changed during the read-modify-write sequence, ie. when hardware sets eg. an interrupt request flag between the read and the write of the read- modify-write sequence. the hardware protection logic guarantees that only the intended bit(s) is/are effected by the write-back operation. note: if a conflict occurs between a bit manipulation generated by hardware and an intended software access the software access has priority and determines the final value of the respective bit. a summary of the protected bits implemented in the c165h can be found at the end of chapter ?architectural overview?.
c165h central processor unit data sheet 64 2001-04-19 p r e l i m i n a r y - exc er p t - 5.3 instruction state times basically, the time to execute an instruction depends on where the instruction is fetched from, and where possible operands are read from or written to. the fastest processing mode of the c165h is to execute a program fetched from the internal code memory. in that case most of the instructions can be processed within just one machine cycle, which is also the general minimum execution time. all external memory accesses are performed by the c165h?s on-chip external bus controller (ebc), which works in parallel with the cpu. this section summarizes the execution times in a very condensed way. a detailled description of the execution times for the various instructions and the specific exceptions can be found in the ?c16x family instruction set manual? . the table below shows the minimum execution times required to process a c165h instruction fetched from the internal ram or from external memory. these execution times apply to most of the c165h instructions - except some of the branches, the multiplication, the division and a special move instruction. the numbers in the table are in units of [ns], refer to a cpu clock of 20 mhz and assume no waitstates. table 10 minimum execution times execution from the internal ram provides flexibility in terms of loadable and modifyable code on the account of execution time. execution from external memory strongly depends on the selected bus mode and the programming of the bus cycles (waitstates). the operand and instruction accesses listed below can extend the execution time of an instruction:  internal ram operand reads via indirect addressing modes  internal sfr operand reads immediately after writing  external operand reads  external operand writes instruction fetch word operand access memory area word instruction doubleword instruction read from write to internal ram 6 8 0/1 0 16-bit demux bus 2 4 2 2 16-bit mux bus 3 6 3 3 8-bit demux bus 4 8 4 4 8-bit mux bus 6 12 6 6
c165h central processor unit data sheet 65 2001-04-19 p r e l i m i n a r y - exc er pt -  jumps to non-aligned double word instructions in the internal rom space  testing branch conditions immediately after psw writes 5.4 cpu special function registers the core cpu requires a set of special function registers (sfrs) to maintain the system state information, to supply the alu with register-addressable constants and to control system and bus configuration, multiply and divide alu operations, code memory segmentation, data memory paging, and accesses to the general purpose registers and the system stack. the access mechanism for these sfrs in the cpu core is identical to the access mechanism for any other sfr. since all sfrs can simply be controlled by means of any instruction, which is capable of addressing the sfr memory space, a lot of flexibility has been gained, without the need to create a set of system-specific instructions. note, however, that there are user access restrictions for some of the cpu core sfrs to ensure proper processor operations. the instruction pointer ip and code segment pointer csp cannot be accessed directly at all. they can only be changed indirectly via branch instructions. the psw, sp, and mdc registers can be modified not only explicitly by the programmer, but also implicitly by the cpu during normal instruction processing. note that any explicit write request (via software) to an sfr supersedes a simultaneous modification by hardware of the same register. note: any write operation to a single byte of an sfr clears the non-addressed complementary byte within the specified sfr. non-implemented (reserved) sfr bits cannot be modified, and will always supply a read value of '0'. the system configuration register syscon this bit-addressable register provides general system configuration and control functions. the reset value for register syscon depends on the state of the port0 pins during reset (see hardware effectable bits).
c165h central processor unit data sheet 66 2001-04-19 p r e l i m i n a r y - exc er p t - syscon (ff12 h / 89 h ) sfr reset value: 0xx0 h bit function xper-share reserved the xper-share mode, known from other c16x infineon derivatives, is not supported in the c165h. this bit must be set to ? 0 ? signal. visible visible mode control ? 0 ? : accesses to xbus peripherals are done internally ? 1 ? : xbus peripheral accesses are made visible on the external pins xpen xbus peripheral enable bit ? 0 ? : accesses to the on-chip x-peripherals and their functions are disabled ? 1 ? : the on-chip x-peripherals are enabled and can be accessed note: this bit is valid only for derivatives that contain x-peripherals. oscenbl oscillator watchdog enable bit ? 0 ? : the oscillator watchdog is disabled. default configuration. ? 1 ? : the oscillator watchdog is enabled. cscfg chip select configuration control ? 0 ? : latched cs mode. the cs signals are latched internally and driven to the enabled port pins synchronously. ? 1 ? : unlatched cs mode. the cs signals are directly derived from the address and driven to the enabled port pins. wrcfg write configuration control (set according to pin p0h.0 during reset) ? 0 ? :pins wr and bhe retain their normal function ? 1 ? :pin wr acts as wrl , pin bhe acts as wrh clken system clock output enable (clkout) ? 0 ? : clkout disabled: pin may be used for general purpose i/o ? 1 ? : clkout enabled: pin outputs the system clock signal bytdis disable/enable control for pin bhe (set according to data bus width) ? 0 ? :pin bhe enabled ? 1 ? :pin bhe disabled, pin may be used for general purpose i/o romen internal boot-rom enable ? 0 ? : internal boot-rom is disabled. access of the lower 32k address space will be linked to external memory. during normal operation, bit romen must always be set to ? 0 ? signal ? 1 ? : internal boot-rom is enabled. this bit is only set in bsl mode. note: during bsl mode, if the lowest 32k of external memory needs to be programmed, bit romen must be set to ?0? signal. after bsl mode, make sure that bit romen is cleared. xpen xper- share visi ble - - rom s1 wr cfg 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 - - rw rw rw rw rw rw stksz sgt dis rom en rw byt dis clk en rw rw rw rw rw osc enbl cs cfg
c165h central processor unit data sheet 67 2001-04-19 p r e l i m i n a r y - exc er pt - note: register syscon cannot be changed after execution of the einit instruction. system clock output enable (clken) the system clock output function is enabled by setting bit clken in register syscon to '1'. if enabled, port pin p3.15 takes on its alternate function as clkout output pin. the clock output is a 50 % duty cycle clock whose frequency equals the cpu operating frequency (f out = f cpu ). note: the output driver of port pin p3.15 is switched on automatically, when the clkout function is enabled. the port direction bit is disregarded. after reset, the clock output function is disabled (clken = ?0?). segmentation disable/enable control (sgtdis) bit sgtdis allows to select either the segmented or non-segmented memory mode. in non-segmented memory mode (sgtdis='1') it is assumed that the code address space is restricted to 64 kbytes (segment 0) and thus 16 bits are sufficient to represent all code addresses. for implicit stack operations (call or ret) the csp register is totally ignored and only the ip is saved to and restored from the stack. in segmented memory mode (sgtdis='0') it is assumed that the whole address space is available for instructions. for implicit stack operations (call or ret) the csp register and the ip are saved to and restored from the stack. after reset the segmented memory mode is selected. note: bit sgtdis controls if the csp register is pushed onto the system stack in addition to the ip register before an interrupt service routine is entered, and it is repopped when the interrupt service routine is left again. sgtdis segmentation disable/enable control ? 0 ? : segmentation enabled (csp and ip are saved/restored during interrupt entry/exit) ? 1 ? : segmentation disabled (only ip is saved/restored) roms1 reserved the roms1, known from other c16x infineon derivatives, is not supported in the c165h. this bit must be set to ? 0 ? signal. stksz system stack size selects the size of the system stack (in the internal ram) from 32 to 1024 words bit function
c165h central processor unit data sheet 68 2001-04-19 p r e l i m i n a r y - exc er p t - system stack size (stksz) this bitfield defines the size of the physical system stack, which is located in the internal ram of the c165h. an area of 32...512 words or all of the internal ram may be dedicated to the system stack. a so-called ?circular stack? mechanism allows to use a bigger virtual stack than this dedicated ram area. these techniques as well as the encoding of bitfield stksz are described in more detail in chapter ?system programming?. the processor status word psw this bit-addressable register reflects the current state of the microcontroller. two groups of bits represent the current alu status, and the current cpu interrupt status. a separate bit (usr0) within register psw is provided as a general purpose user flag. psw (ff10 h / 88 h ) sfr reset value: 0000 h alu status (n, c, v, z, e, mulip) the condition flags (n, c, v, z, e) within the psw indicate the alu status due to the last recently performed alu operation. they are set by most of the instructions due to specific rules, which depend on the alu or data movement operation performed by an instruction. after execution of an instruction which explicitly updates the psw register, the condition flags cannot be interpreted as described in the following, because any explicit write to the psw register supersedes the condition flag values, which are implicitly generated by the cpu. explicitly reading the psw register supplies a read value which represents the state of the psw register after execution of the immediately preceding instruction. note: after reset, all of the alu status bits are cleared.  n-flag: for most of the alu operations, the n-flag is set to '1', if the most significant bit of the result contains a '1', otherwise it is cleared. in the case of integer operations the n-flag can be interpreted as the sign bit of the result (negative: n=?1?, positive: n=?0?). negative numbers are always represented as the 2's complement of the corresponding positive number. the range of signed numbers extends from '?8000 h ' to '+7fff h ' for the word data type, or from '?80 h ' to '+7f h ' for the byte data type.for boolean bit operations with only one operand the n-flag represents the previous state of the specified bit. for boolean bit operations with two operands the n-flag represents the logical xoring of the two specified bits. hld en mul ip usr0 - n zc v e 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw - rw rw rw - rw - rw ien - - ilvl rw
c165h central processor unit data sheet 69 2001-04-19 p r e l i m i n a r y - exc er pt -  c-flag: after an addition the c-flag indicates that a carry from the most significant bit of the specified word or byte data type has been generated. after a subtraction or a comparison the c-flag indicates a borrow, which represents the logical negation of a carry for the addition. this means that the c-flag is set to '1', if no carry from the most significant bit of the specified word or byte data type has been generated during a subtraction, which is performed internally by the alu as a 2's complement addition, and the c-flag is cleared when this complement addition caused a carry. the c-flag is always cleared for logical, multiply and divide alu operations, because these operations cannot cause a carry anyhow. for shift and rotate operations the c-flag represents the value of the bit shifted out last. if a shift count of zero is specified, the c-flag will be cleared. the c-flag is also cleared for a prioritize alu operation, because a '1' is never shifted out of the msb during the normalization of an operand. for boolean bit operations with only one operand the c-flag is always cleared. for boolean bit operations with two operands the c-flag represents the logical anding of the two specified bits.  v-flag: for addition, subtraction and 2's complementation the v-flag is always set to '1', if the result overflows the maximum range of signed numbers, which are representable by either 16 bits for word operations ('?8000 h ' to '+7fff h '), or by 8 bits for byte operations ('?80 h ' to '+7f h '), otherwise the v-flag is cleared. note that the result of bit function n negative result set, when the result of an alu operation is negative. c carry flag set, when the result of an alu operation produces a carry bit. v overflow result set, when the result of an alu operation produces an overflow. z zero flag set, when the result of an alu operation is zero. e end of table flag set, when the source operand of an instruction is 8000 h or 80 h . mulip multiplication/division in progress ? 0 ? : there is no multiplication/division in progress. ? 1 ? : a multiplication/division has been interrupted. usr0 user general purpose flag may be used by the application software. hlden, ilvl, ien interrupt and ebc control fields define the response to interrupt requests and enable external bus arbitration. (described in section ? interrupt and trap functions ? )
c165h central processor unit data sheet 70 2001-04-19 p r e l i m i n a r y - exc er p t - an integer addition, integer subtraction, or 2's complement is not valid, if the v-flag indicates an arithmetic overflow. for multiplication and division the v-flag is set to '1', if the result cannot be represented in a word data type, otherwise it is cleared. note that a division by zero will always cause an overflow. in contrast to the result of a division, the result of a multiplication is valid regardless of whether the v-flag is set to '1' or not. since logical alu operations cannot produce an invalid result, the v-flag is cleared by these operations. the v-flag is also used as 'sticky bit' for rotate right and shift right operations. with only using the c-flag, a rounding error caused by a shift right operation can be estimated up to a quantity of one half of the lsb of the result. in conjunction with the v-flag, the c-flag allows evaluating the rounding error with a finer resolution (see table below). for boolean bit operations with only one operand the v-flag is always cleared. for boolean bit operations with two operands the v-flag represents the logical oring of the two specified bits. table 11 shift right rounding error evaluation  z-flag: the z-flag is normally set to '1', if the result of an alu operation equals zero, otherwise it is cleared. for the addition and subtraction with carry the z-flag is only set to '1', if the z-flag already contains a '1' and the result of the current alu operation additionally equals zero. this mechanism is provided for the support of multiple precision calculations. for boolean bit operations with only one operand the z-flag represents the logical negation of the previous state of the specified bit. for boolean bit operations with two operands the z-flag represents the logical noring of the two specified bits. for the prioritize alu operation the z-flag indicates, if the second operand was zero or not.  e-flag: the e-flag can be altered by instructions, which perform alu or data movement operations. the e-flag is cleared by those instructions which cannot be reasonably used for table search operations. in all other cases the e-flag is set depending on the value of the source operand to signify whether the end of a search table is reached or not. if the value of the source operand of an instruction equals the lowest negative number, which is representable by the data format of the corresponding instruction ('8000 h ' for the word data type, or '80 h ' for the byte data type), the e-flag is set to '1', otherwise it is cleared. c-flag v-flag rounding error quantity 0 0 1 1 0 1 0 1 - no rounding error - 0 < rounding error < 1 / 2 lsb rounding error = 1 / 2 lsb rounding error > 1 / 2 lsb
c165h central processor unit data sheet 71 2001-04-19 p r e l i m i n a r y - exc er pt -  mulip-flag: the mulip-flag will be set to '1' by hardware upon the entrance into an interrupt service routine, when a multiply or divide alu operation was interrupted before completion. depending on the state of the mulip bit, the hardware decides whether a multiplication or division must be continued or not after the end of an interrupt service. the mulip bit is overwritten with the contents of the stacked mulip-flag when the return-from-interrupt-instruction (reti) is executed. this normally means that the mulip-flag is cleared again after that. note: the mulip flag is a part of the task environment! when the interrupting service routine does not return to the interrupted multiply/divide instruction (ie. in case of a task scheduler that switches between independent tasks), the mulip flag must be saved as part of the task environment and must be updated accordingly for the new task before this task is entered. cpu interrupt status (ien, ilvl) the interrupt enable bit allows to globally enable (ien=?1?) or disable (ien=?0?) interrupts. the four-bit interrupt level field (ilvl) specifies the priority of the current cpu activity. the interrupt level is updated by hardware upon entry into an interrupt service routine, but it can also be modified via software to prevent other interrupts from being acknowledged. in case an interrupt level '15' has been assigned to the cpu, it has the highest possible priority, and thus the current cpu operation cannot be interrupted except by hardware traps or external non-maskable interrupts. for details please refer to chapter ?interrupt and trap functions?. after reset all interrupts are globally disabled, and the lowest priority (ilvl=0) is assigned to the initial cpu activity. the instruction pointer ip this register determines the 16-bit intra-segment address of the currently fetched instruction within the code segment selected by the csp register. the ip register is not mapped into the c165h's address space, and thus it is not directly accessable by the programmer. the ip can, however, be modified indirectly via the stack by means of a return instruction. the ip register is implicitly updated by the cpu for branch instructions and after instruction fetch operations.
c165h central processor unit data sheet 72 2001-04-19 p r e l i m i n a r y - exc er p t - ip (---- / --) --- reset value: 0000 h the code segment pointer csp this non-bit addressable register selects the code segment being used at run-time to access instructions. the lower 8 bits of register csp select one of up to 256 segments of 64 kbytes each, while the upper 8 bits are reserved for future use. csp (fe08 h / 04 h ) sfr reset value: 0000 h code memory addresses are generated by directly extending the 16-bit contents of the ip register by the contents of the csp register as shown in the figure below. in case of the segmented memory mode the selected number of segment address bits (via bitfield salsel) of register csp is output on the respective segment address pins of port 4 for all external code accesses. for non-segmented memory mode or single chip mode the content of this register is not significant, because all code acccesses are automatically restricted to segment 0. note: the csp register can only be read but not written by data operations. it is, however, modified either directly by means of the jmps and calls instructions, or indirectly via the stack by means of the rets and reti instructions. upon the acceptance of an interrupt or the execution of a software trap instruction, the csp register is automatically set to zero. bit function ip specifies the intra segment offset, from where the current instruction is to be fetched. ip refers to the current segment . bit function segnr segment number specifies the code segment, from where the current instruction is to be fetched. segnr is ignored, when segmentation is disabled. 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 (r)(w) ip - - -- - 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 - - - r - - - - -- - - segnr
c165h central processor unit data sheet 73 2001-04-19 p r e l i m i n a r y - exc er pt - figure 16 addressing via the code segment pointer note: when segmentation is disabled, the ip value is used directly as the 16-bit address. data page pointers dpp0, dpp1, dpp2, dpp3 these four non-bit addressable registers select up to four different data pages being active simultaneously at run-time. the lower 10 bits of each dpp register select one of the 1024 possible 16-kbyte data pages while the upper 6 bits are reserved for future use. the dpp registers allow to access the entire memory space in pages of 16 kbytes each. the dpp registers are implicitly used, whenever data accesses to any memory location are made via indirect or direct long 16-bit addressing modes (except for override accesses via extended instructions and pec data transfers). after reset, the data page pointers are initialized in a way that all indirect or direct long 16-bit addresses result in identical 18-bit addresses. this allows to access data pages 3...0 within segment 0 as shown in the figure below. if the user does not want to use any data paging, no further action is required. mca02265 255 1 15 0 ip register 254 0 code segment ff ? ffff h fe ? 0000 h 01 ? 0000 h 00 ? 0000 h csp register 15 0 24/20/18-bit physical code address
c165h central processor unit data sheet 74 2001-04-19 p r e l i m i n a r y - exc er p t - dpp0 (fe00 h / 00 h ) sfr reset value: 0000 h dpp1 (fe02 h / 01 h ) sfr reset value: 0001 h dpp2 (fe04 h / 02 h ) sfr reset value: 0002 h dpp3 (fe06 h / 03 h ) sfr reset value: 0003 h data paging is performed by concatenating the lower 14 bits of an indirect or direct long 16-bit address with the contents of the dpp register selected by the upper two bits of the 16-bit address. the content of the selected dpp register specifies one of the 1024 possible data pages. this data page base address together with the 14-bit page offset forms the physical 24-bit address (selectable part is driven to the address pins). in case of non-segmented memory mode, only the two least significant bits of the implicitly selected dpp register are used to generate the physical address. thus, extreme care should be taken when changing the content of a dpp register, if a non- segmented memory model is selected, because otherwise unexpected results could occur. bit function dppxpn data page number of dppx specifies the data page selected via dppx. only the least significant two bits of dppx are significant, when segmentation is disabled. - - - 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 - rw - - - - -- - - dpp0pn - - - 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 - rw - - - - -- - - dpp1pn - - - 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 - rw - - - - -- - - dpp2pn - - - 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 - rw - - - - -- - - dpp3pn
c165h central processor unit data sheet 75 2001-04-19 p r e l i m i n a r y - exc er pt - in case of the segmented memory mode the selected number of segment address bits (via bitfield salsel) of the respective dpp register is output on the respective segment address pins of port 4 for all external data accesses. a dpp register can be updated via any instruction, which is capable of modifying an sfr. note: due to the internal instruction pipeline, a new dpp value is not yet usable for the operand address calculation of the instruction immediately following the instruction updating the dpp register. figure 17 addressing via the data page pointers context pointer cp this non-bit addressable register is used to select the current register context. this means that the cp register value determines the address of the first general purpose register (gpr) within the current register bank of up to 16 wordwide and/or bytewide gprs. mca02264 1023 data pages 1022 1021 3 2 1 0 dpp registers dpp3-11 dpp2-10 dpp1-01 dpp0-00 15 14 0 16-bit data address 14-bit intra-page address (concatenated with content of dppx). affer reset or with segmentation disabled the dpp registers select data pages 3...0. all of the internal memory is accessible in these cases.
c165h central processor unit data sheet 76 2001-04-19 p r e l i m i n a r y - exc er p t - cp (fe10 h / 08 h ) sfr reset value: fc00 h note: it is the user's responsibility that the physical gpr address specified via cp register plus short gpr address must always be an internal ram location. if this condition is not met, unexpected results may occur.  do not set cp below the iram start address, ie. 00?fa00 h /00?f600 h /00?f200 h (1/2/3 kb)  do not set cp above 00?fdfe h  be careful using the upper gprs with cp above 00?fde0 h the cp register can be updated via any instruction which is capable of modifying an sfr. note: due to the internal instruction pipeline, a new cp value is not yet usable for gpr address calculations of the instruction immediately following the instruction updating the cp register. the switch context instruction (scxt) allows to save the content of register cp on the stack and updating it with a new value in just one machine cycle. bit function cp modifiable portion of register cp specifies the (word) base address of the current register bank. when writing a value to register cp with bits cp.11...cp.9 = ? 000 ? , bits cp.11...cp.10 are set to ? 11 ? by hardware, in all other cases all bits of bit field ? cp ? receive the written value. 1 0 1 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 r rw r r r 11 r cp
c165h central processor unit data sheet 77 2001-04-19 p r e l i m i n a r y - exc er pt - figure 18 register bank selection via register cp several addressing modes use register cp implicitly for address calculations. the addressing modes mentioned below are described in chapter ?instruction set summary?. short 4-bit gpr addresses (mnemonic: rw or rb) specify an address relative to the memory location specified by the contents of the cp register, ie. the base of the current register bank. depending on whether a relative word (rw) or byte (rb) gpr address is specified, the short 4-bit gpr address is either multiplied by two or not before it is added to the content of register cp (see figure below). thus, both byte and word gpr accesses are possible in this way. gprs used as indirect address pointers are always accessed wordwise. for some instructions only the first four gprs can be used as indirect address pointers. these gprs are specified via short 2-bit gpr addresses. the respective physical address calculation is identical to that for the short 4-bit gpr addresses. mcd02003 r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 context pointer (cp) + 30 (cp) + 28 (cp) + 2 (cp) internal ram . . .
c165h central processor unit data sheet 78 2001-04-19 p r e l i m i n a r y - exc er p t - short 8-bit register addresses (mnemonic: reg or bitoff) within a range from f0 h to ff h interpret the four least significant bits as short 4-bit gpr address, while the four most significant bits are ignored. the respective physical gpr address calculation is identical to that for the short 4-bit gpr addresses. for single bit accesses on a gpr, the gpr's word address is calculated as just described, but the position of the bit within the word is specified by a separate additional 4-bit value. figure 19 implicit cp use by short gpr addressing modes stack pointer sp this non-bit addressable register is used to point to the top of the internal system stack (tos). the sp register is pre-decremented whenever data is to be pushed onto the stack, and it is post-incremented whenever data is to be popped from the stack. thus, the system stack grows from higher toward lower memory locations. since the least significant bit of register sp is tied to '0' and bits 15 through 12 are tied to '1' by hardware, the sp register can only contain values from f000 h to fffe h . this allows to access a physical stack within the internal ram of the c165h. a virtual stack (usually bigger) can be realized via software. this mechanism is supported by registers stkov and stkun (see respective descriptions below). the sp register can be updated via any instruction, which is capable of modifying an sfr. note: due to the internal instruction pipeline, a pop or return instruction must not immediately follow an instruction updating the sp register. for word gpr accesses accesses for byte gpr control 1111 specified by reg or bitoff context pointer + 4-bit gpr address 2 * mcd02005 internal gprs ram must be within the ram area internal
c165h central processor unit data sheet 79 2001-04-19 p r e l i m i n a r y - exc er pt - sp (fe12 h / 09 h ) sfr reset value: fc00 h stack overflow pointer stkov this non-bit addressable register is compared against the sp register after each operation, which pushes data onto the system stack (eg. push and call instructions or interrupts) and after each subtraction from the sp register. if the content of the sp register is less than the content of the stkov register, a stack overflow hardware trap will occur. since the least significant bit of register stkov is tied to '0' and bits 15 through 12 are tied to '1' by hardware, the stkov register can only contain values from f000 h to fffe h . stkov (fe14 h / 0a h ) sfr reset value: fa00 h the stack overflow trap (entered when (sp) < (stkov)) may be used in two different ways:  fatal error indication treats the stack overflow as a system error through the associated trap service routine. under these circumstances data in the bottom of the stack may have been overwritten by the status information stacked upon servicing the stack overflow trap. bit function sp modifiable portion of register sp specifies the top of the internal system stack. bit function stkov modifiable portion of register stkov specifies the lower limit of the internal system stack. 1 0 1 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 r rw r r r 11 r sp 1 0 1 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 r rw r r r 11 r stkov
c165h central processor unit data sheet 80 2001-04-19 p r e l i m i n a r y - exc er p t -  automatic system stack flushing allows to use the system stack as a 'stack cache' for a bigger external user stack. in this case register stkov should be initialized to a value, which represents the desired lowest top of stack address plus 12 according to the selected maximum stack size. this considers the worst case that will occur, when a stack overflow condition is detected just during entry into an interrupt service routine. then, six additional stack word locations are required to push ip, psw, and csp for both the interrupt service routine and the hardware trap service routine. more details about the stack overflow trap service routine and virtual stack management are given in chapter ?system programming?. stack underflow pointer stkun this non-bit addressable register is compared against the sp register after each operation, which pops data from the system stack (eg. pop and ret instructions) and after each addition to the sp register. if the content of the sp register is greater than the the content of the stkun register, a stack underflow hardware trap will occur. since the least significant bit of register stkun is tied to '0' and bits 15 through 12 are tied to '1' by hardware, the stkun register can only contain values from f000 h to fffe h . stkun (fe16 h / 0b h ) sfr reset value: fc00 h the stack underflow trap (entered when (sp) > (stkun)) may be used in two different ways:  fatal error indication treats the stack underflow as a system error through the associated trap service routine.  automatic system stack refilling allows to use the system stack as a 'stack cache' for a bigger external user stack. in this case register stkun should be initialized to a value, which represents the desired highest bottom of stack address. more details about the stack underflow trap service routine and virtual stack management are given in chapter ?system programming?. bit function stkun modifiable portion of register stkun specifies the upper limit of the internal system stack. 1 0 1 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 r rw r r r 11 r stkun
c165h central processor unit data sheet 81 2001-04-19 p r e l i m i n a r y - exc er pt - scope of stack limit control the stack limit control realized by the register pair stkov and stkun detects cases where the stack pointer sp is moved outside the defined stack area either by add or sub instructions or by push or pop operations (explicit or implicit, ie. call or ret instructions). this control mechanism is not triggered, ie. no stack trap is generated, when  the stack pointer sp is directly updated via mov instructions  the limits of the stack area (stkov, stkun) are changed, so that sp is outside of the new limits. multiply/divide high register mdh this register is a part of the 32-bit multiply/divide register, which is implicitly used by the cpu, when it performs a multiplication or a division. after a multiplication, this non-bit addressable register represents the high order 16 bits of the 32-bit result. for long divisions, the mdh register must be loaded with the high order 16 bits of the 32-bit dividend before the division is started. after any division, register mdh represents the 16-bit remainder. mdh (fe0c h / 06 h ) sfr reset value: 0000 h whenever this register is updated via software, the multiply/divide register in use (mdriu) flag in the multiply/divide control register (mdc) is set to '1'. when a multiplication or division is interrupted before its completion and when a new multiply or divide operation is to be performed within the interrupt service routine, register mdh must be saved along with registers mdl and mdc to avoid erroneous results. a detailed description of how to use the mdh register for programming multiply and divide algorithms can be found in chapter ?system programming?. multiply/divide low register mdl this register is a part of the 32-bit multiply/divide register, which is implicitly used by the cpu, when it performs a multiplication or a division. after a multiplication, this non-bit addressable register represents the low order 16 bits of the 32-bit result. for long divisions, the mdl register must be loaded with the low order 16 bits of the 32-bit bit function mdh specifies the high order 16 bits of the 32-bit multiply and divide register md. 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw mdh
c165h central processor unit data sheet 82 2001-04-19 p r e l i m i n a r y - exc er p t - dividend before the division is started. after any division, register mdl represents the 16- bit quotient. mdl (fe0e h / 07 h ) sfr reset value: 0000 h whenever this register is updated via software, the multiply/divide register in use (mdriu) flag in the multiply/divide control register (mdc) is set to '1'. the mdriu flag is cleared, whenever the mdl register is read via software. when a multiplication or division is interrupted before its completion and when a new multiply or divide operation is to be performed within the interrupt service routine, register mdl must be saved along with registers mdh and mdc to avoid erroneous results. a detailed description of how to use the mdl register for programming multiply and divide algorithms can be found in chapter ?system programming?. multiply/divide control register mdc this bit addressable 16-bit register is implicitly used by the cpu, when it performs a multiplication or a division. it is used to store the required control information for the corresponding multiply or divide operation. register mdc is updated by hardware during each single cycle of a multiply or divide instruction. mdc (ff0e h / 87 h ) sfr reset value: 0000 h when a division or multiplication was interrupted before its completion and the multiply/ divide unit is required, the mdc register must first be saved along with registers mdh and mdl (to be able to restart the interrupted operation later), and then it must be cleared prepare it for the new calculation. after completion of the new division or multiplication, the state of the interrupted multiply or divide operation must be restored. the mdriu flag is the only portion of the mdc register which might be of interest for the user. the remaining portions of the mdc register are reserved for dedicated use by the bit function mdl specifies the low order 16 bits of the 32-bit multiply and divide register md. 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw mdl - !! - - 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 - r(w) - - - - -- - - !! !! !! !! !! !! - - - - r(w) r(w) r(w) r(w) r(w) r(w) r(w) mdr iu
c165h central processor unit data sheet 83 2001-04-19 p r e l i m i n a r y - exc er pt - hardware, and should never be modified by the user in another way than described above. otherwise, a correct continuation of an interrupted multiply or divide operation cannot be guaranteed. a detailed description of how to use the mdc register for programming multiply and divide algorithms can be found in chapter ?system programming?. constant zeros register zeros all bits of this bit-addressable register are fixed to '0' by hardware. this register can be read only. register zeros can be used as a register-addressable constant of all zeros, ie. for bit manipulation or mask generation. it can be accessed via any instruction, which is capable of addressing an sfr. zeros (ff1c h / 8e h ) sfr reset value: 0000 h constant ones register ones all bits of this bit-addressable register are fixed to '1' by hardware. this register can be read only. register ones can be used as a register-addressable constant of all ones, ie. for bit manipulation or mask generation. it can be accessed via any instruction, which is capable of addressing an sfr. bit function mdriu multiply/divide register in use ? 0 ? : cleared, when register mdl is read via software. ? 1 ? : set when register mdl or mdh is written via software, or when a multiply or divide instruction is executed. !! internal machine status the multiply/divide unit uses these bits to control internal operations. never modify these bits without saving and restoring register mdc. 0 0 0 0 0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 r r r r r r 00 0 r 0 0 0 0 0 0 0 0 r r r r r r r r r
c165h central processor unit data sheet 84 2001-04-19 p r e l i m i n a r y - exc er p t - ones (ff1e h / 8f h ) sfr reset value: ffff h 5.5 pec - extension of functionality introduction compared to existing c16x architecture, the pec transfer function is enhanced by extended functionality. the extended pec function is a further step into dma control functionality. it especially supports integrated system design with xbus as system bus. note: the device address decoding structure is always based on 24-bit addresses. but due to the limited number of port p4 pins, only the address bits a22:a16 can be made visible on the external x-bus interface. the extended pec functions are defined as follows: ? source pointer and destination pointer are extended to 24-bit pointer, thus enabling pec controlled data transfer between any two locations within the total address space. both 8-bit segment numbers of every source/destination pointer pair are defined in one 16-bit sfr register; thus, 8 pec segment number registers are available for the 8 pec channels. ? two of the pec channels are expanded by additional 16-bit transfer count registers; when enabled, the original 8-bit bytecount in the control register serves as package length count, thus defining the amount of bytes or words to be transferred with one request. in c165h the package size is always limited to one transfer. ? for always two channels a chaining feature is provided. when enabled in the pec control register, a termination interrupt of one channel will automatically switch transfer control to the other channel of the channel pair. 24-bit extension of source and destination pointers the source and destination pointers specify the locations between which the data is to be moved. for each of the eight pec channels the source and destination pointers are specified by one sfr register and two iram memory locations. one sfr register stores the 8-bit segment number of the source (pecssn) and the 8-bit segment number of the destination (pecdsn) location in a respective 16-bit pec segment number register (pecsnx). the respective segment offset of source and destination are stored in iram memory location identical to the iram locations of srcpx and dstpx pointers of full- custom c16x standard pec channels - thus the extension is fully compatible. with the segment number extension of source and destination, data can be transferred by a pec transfer between any two locations within the 8 mbyte address space of the c165h. 1 1 1 1 1 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 r r r r r r 11 1 r 1 1 1 1 1 1 1 1 r r r r r r r r r
c165h central processor unit data sheet 85 2001-04-19 p r e l i m i n a r y - exc er pt - note: the segment number extension of source and destination is provided for all 8 pec channels. after reset, all 8 segment number registers pecsnx are cleared, providing full compatibility to fc-c16x pec channels. the pec segment number registers pecsnx are defined as follows: pecsnx (addresses see table) sfr reset value: 0000 h bit function pecssn pec source segment number 8-bit segment number used for addressing the source of the respective pec transfer. note: bits 6:0 can be used externally (address bits a22:a16). due to the limited number of pins, the upper bit 7 can not be used externally but can still be used for chip select (cs) generation. pecdsn pec destination segment number 8-bit segment number used for addressing the destination of the respective pec transfer. note: bits 14:8 can be used externally (address bits a22:a16). due to the limited number of pins, the upper bit 15 can not be used externally but can still be used for chip select (cs) generation. table 12 pec segment number register addresses register address reg. space register address reg. space pecsn0 fed0 h / 68 h sfr pecsn4 fed8 h / 6c h sfr pecsn1 fed2 h / 69 h sfr pecsn5 feda h / 6d h sfr pecsn2 fed4 h / 6a h sfr pecsn6 fedc h / 6e h sfr pecsn3 fed6 h / 6b h sfr pecsn7 fede h / 6f h sfr 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw pecssn rw pecdsn
c165h central processor unit data sheet 86 2001-04-19 p r e l i m i n a r y - exc er p t - extended pec channel control the pec control registers with the extended functionality and their application for new pec control are defined as follows: peccx (addresses: see table) sfr reset value: 0000 h bit function count pec transfer count counts pec transfers (bytes or words) and influences the channel?s action bwt byte / word transfer selection 0: transfer a word 1: transfer a byte inc increment control (modification of srcpx or dstpx) 0 0: pointers are not modified 0 1: increment dstpx by 1 or 2 (bwt) 1 0: increment srcpx by 1 or 2 (bwt) 1 1: reserved. do not use this combination. (changed to 10 by hardware) cl channel link control 0: pec channels work independent 1: pairs of channels are linked together clt channel link toggle state 0: even numbered pec channel of linked channels active 1: odd numbered pec channel of linked channels active pt package transfer 0: single transfer; extended count2 not enabled 1: package transfer; extended count2 enabled (only for channels 0 and 2) note: package transfer is only supported in pecc0 and pecc2 bwt - pt 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw cl rw rw rw - rw clt - inc count
c165h central processor unit data sheet 87 2001-04-19 p r e l i m i n a r y - exc er pt - pec control register addresses byte/word transfer bit bwt controls, if a byte or a word is moved during a pec service cycle. this selection controls the transferred data size and the increment step for the modified pointer. increment control field inc controls, if one of the pec pointers is incremented after the pec transfer. it is not possible to increment both pointers, however. if the pointers are not modified (inc=?00?), the respective channel will always move data from the same source to the same destination. note: the reserved combination ?11? is changed to ?10? by hardware. however, it is not recommended to use this combination. the pec transfer count field count controls the action of a respective pec channel, where the content of bit field count at the time the request is activated selects the action. count may allow a specified number of pec transfers, unlimited transfers or no pec service at all. the table below summarizes, how the count field itself, the interrupt requests flag ir and the pec channel action depends on the previous content of count. the pec transfer counter allows to service a specified number of requests by the respective pec channel, and then (when count reaches 00 h ) activate the interrupt service routine, which is associated with the priority level. after each pec transfer the count field is decremented and the request flag is cleared to indicate that the request has been serviced. register address reg. space register address reg. space pecc0 fec0 h / 60 h sfr pecc4 fec8 h / 64 h sfr pecc1 fec2 h / 61 h sfr pecc5 feca h / 65 h sfr pecc2 fec4 h / 62 h sfr pecc6 fecc h / 66 h sfr pecc3 fec6 h / 63 h sfr pecc7 fece h / 67 h sfr previous count modified count ir after pec service action of pec channel and comments ff h ff h ? 0 ? move a byte / word continuous transfer mode, ie. count is not modified fe h ..02 h fd h ..01 h ? 0 ? move a byte / word and decrement count 01 h 00 h ? 1 ? move a byte / word leave request flag set, which triggers another request 00 h 00 h ( ? 1 ? ) no action! activate interrupt service routine rather than pec channel.
c165h central processor unit data sheet 88 2001-04-19 p r e l i m i n a r y - exc er p t - continuous transfers are selected by the value ff h in bit field count. in this case count is not modified and the respective pec channel services any request until it is disabled again. when count is decremented from 01 h to 00 h after a transfer, the request flag is not cleared, which generates another request from the same source. when count already contains the value 00 h , the respective pec channel remains idle and the associated interrupt service routine is activated instead. this allows to choose, if a level 15 or 14 request is to be serviced by the pec or by the interrupt service routine. note: pec transfers are only executed, if their priority level is higher than the cpu level, ie. only pec channels 7...4 are processed, while the cpu executes on level 14. all interrupt request sources that are enabled and programmed for pec service should use different channels. otherwise only one transfer will be performed for all simultaneous requests. when count is decremented to 00 h , and the cpu is to be interrupted, an incorrect interrupt vector will be generated. channel link control bit cl controls the channel link mode. in this mode pec channels work by pair (channels 0 and 1, 2 and 3, 4 and 5, 6 and 7). the channel link mode is enabled for one pair when the cl bit is set in any of the 2 peccx registers. in this case, the 2 channels handle pec requests alternative to each other. the whole data transfer is divided into several block transfers where each block is controlled by a pec channel. when a block transfer is completed, a channel link interrupt is generated and the request processing is switched to the other pec channel of the pair. this mechanism allows to set up shadow and multiple buffers for pec transfers by changing pointers and count values of one channel when the other channel is active. the very first transfer is always initiated with the even channel (called channel a, that is channel 0, 2, 4 or 6). when the associated count field reaches 0 (count or count2 depending on the selected mode), the request service is transfered to the odd channel (channel b, that is channel 1, 3, 5 or 7). if the cl bit of the "linked" channel is set and the count field is different from 0, the next pec requests will be serviced by this channel. the channel link interrupts share one common interrupt node (trap number 4c h - vector location 00?0130 h ). this node is controlled by the channel link interrupt sub-node control (clisnc) register. it raises an interrupt request in case of one or more channel link request flag and the respective enable control bit is set in clisnc register. these flags signal a pec condition of the pec linked channels which requires an action from the cpu. the following conditions are possible: 1. in single transfer mode, a count value change from 01 h to 00 h in a linked pec channel and the cl flag is set in the respective pec control register, 2. in packet transfer mode, a count2 value change from 0001 h to 0000 h in a linked pec channel and the cl flag is set in the respective pec control register. in these cases the cpu is requested to update the pec control and pointer registers while the next block transfer is executed. the last block transfer is determined by the missing link bit in the linked pec control register. if a service request hits a linked
c165h central processor unit data sheet 89 2001-04-19 p r e l i m i n a r y - exc er pt - channel with a count field equal to 00h and the channel link flag disabled, a standard interrupt is performed as known from standard pec channels. clisnc (ffa8 h / d4 h ) sfr reset value: 0000 h packet transfer control bit pt is implemented only in pecc0 and pecc2. when set to ?1?, this bit enables the packet transfer mode. in this mode, each service request initiates the transfer of an entire data packet of a fixed size. the count field in the peccx register is used to define the size of the packet (in number of bytes or words depending on the value of bwt). therefore packets up to 256 bytes/words may be transfered. the register pecxc0/2 is then used to specify the number of requests to be serviced by a pec packet transfer before activating the interrupt service routine, which is associated with the priority level. after each pec packet transfer, the count2 field is decremented and the request flag is cleared, and then when count2 reaches 0000 h , an interrupt request is generated to the corresponding interrupt vector. note: in the c165h, the packet size is limited to 1. packet transfers are not supported, but the extended transfer count count2 is used when pt bit is set. bit function xxie channel link interrupt enable bit (individual for each pair of linked channels) ? 0 ? : interrupt request disabled ? 1 ? : interrupt request enabled xxir channel service request flag ? 0 ? : no channel link service request pending ? 1 ? : the channel pair has raised a request to service a pec channel after channel link - - - - - 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 - - rw rw - - rw rw rw - rw - - c6 ir c2 ie c0 ir - - - rw - c6 ie rw c2 ir c0 ie c4 ir c4 ie
c165h central processor unit data sheet 90 2001-04-19 p r e l i m i n a r y - exc er p t - pecxcx (fefy h / 7z h , see table) sfr reset value: 0000 h pec extended control register addresses source and destination pointers specifiy the locations between which the data is to be moved. for pec transfer description refer to chapter 6.3 , page 103, where the pec operation is descriped more in detail. channel link mode for data chaining data chaining with linked pec channels is enabled, if the channel link control bit in peccx register is set to ?1?, either in one or both pec channel control registers of a channel pair. in this case, two pec channels are linked together and handle chained block transfers alternatively to each other. the whole data transfer is divided into several block transfers where each block is controlled by one pec channel of a channel pair. when a data block is completely transferred a channel link interrupt is generated and the pec service request processing is automatically switched to the ?other? pec channel of the channel-pair. thus, pec service requests addressed to a linked pec channel are either handled by linked pec channel a or by linked pec channel b. this channel toggle allows to set up shadow and multiple buffers for pec transfers by changing pointer and count values of one channel while the other channel is active. the following table list the channels that can be linked together and the channel numbers to address the linked channels. bit function count2 extended pec transfer count counts pec transfers and influences the channel ? s action in packet transfer mode register address reg. space register address reg. space pecxc0 fef0 h / 78 h sfr pecxc2 fef2 h / 79 h sfr 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw count2
c165h central processor unit data sheet 91 2001-04-19 p r e l i m i n a r y - exc er pt - for each pair of linked channels, an internal channel flag, the channel link toggle flag clt identifies which of the two pec channels will serve the next pec request. the clt flag is indicated in both peccx registers of two linked pec channels, where the clt bit in channel b always is inverse to the clt bit in channel a. the very first transfer is always started with the channel a if the clt bit was not programmed otherwise before. the clt bit is only valid in case of linked pec channels, indicated by the cl bits of linked channels. if linking is not enabled, the clt bit of both channels is always zero (compatibility!). the internal channel link flag clt toggles, and the other channel begins service with the next request if the "old" channel stops the service (count=0 or count2=0, dependent on the mode), and if the new channel has in its pec control register the cl flag enabled and its transfer count is more than zero. note: with the last transfer of a block transfer (count=0 or count2=0), the channel link control flag cl of that channel is cleared in its peccx register. if the channel link flag cl of the new (chained) pec control register is found to be zero the whole data transfer is finished and the channel link interrupt is coincidently a termination interrupt. the channel link mode is finished and the internal channel toggle flag is cleared after the last transfer of the block, if the cl flags of both pair channels are cleared. table 13 pec channels which could be linked together linked pec channels linked pec channel pec channel a pec channel b channel 0 channel 1 channel 0 channel 2 channel 3 channel 2 channel 4 channel 5 channel 4 channel 6 channel 7 channel 6
c165h interrupt and trap functions data sheet 92 2001-04-19 p r e l i m i n a r y - exc er p t - 6 interrupt and trap functions the architecture of the c165h supports several mechanisms for fast and flexible response to service requests that can be generated from various sources internal or external to the microcontroller. these mechanisms include: normal interrupt processing the cpu temporarily suspends the current program execution and branches to an interrupt service routine in order to service an interrupt requesting device. the current program status (ip, psw, in segmentation mode also csp) is saved on the internal system stack. a prioritization scheme with 16 priority levels allows the user to specify the order in which multiple interrupt requests are to be handled. interrupt processing via the peripheral event controller (pec) a faster alternative to normal software controlled interrupt processing is servicing an interrupt requesting device with the c165h's integrated peripheral event controller (pec). triggered by an interrupt request, the pec performs a single word or byte data transfer between any two locations in segment 0 (data pages 0 through 3) through one of eight programmable pec service channels. during a pec transfer the normal program execution of the cpu is halted for just 1 instruction cycle. no internal program status information needs to be saved. the same prioritization scheme is used for pec service as for normal interrupt processing. pec transfers share the 2 highest priority levels. trap functions trap functions are activated in response to special conditions that occur during the execution of instructions. a trap can also be caused externally by the non-maskable interrupt pin nmi . several hardware trap functions are provided for handling erroneous conditions and exceptions that arise during the execution of an instruction. hardware traps always have highest priority and cause immediate system reaction. the software trap function is invoked by the trap instruction, which generates a software interrupt for a specified interrupt vector. for all types of traps the current program status is saved on the system stack. external interrupt processing although the c165h does not provide dedicated interrupt pins, it allows to connect external interrupt sources and provides several mechanisms to react on external events, including standard inputs, non-maskable interrupts and fast external interrupts. these interrupt functions are alternate port functions, except for the non-maskable interrupt and the reset input.
c165h interrupt and trap functions data sheet 93 2001-04-19 p r e l i m i n a r y - exc er pt - 6.1 interrupt system structure the c165h provides up to 64 separate interrupt nodes that may be assigned to 16 priority levels. the 4 lowest nodes are reserved for the cpu - thus, up to 60 nodes are available for all interrupts. in order to support modular and consistent software design techniques, each source of an interrupt or pec request is supplied with a separate interrupt control register and interrupt vector. the control register contains the interrupt request flag, the interrupt enable bit, and the interrupt priority of the associated source. each source request is activated by one specific event, depending on the selected operating mode of the respective device. the only exceptions are the two serial channels of the table, where an error interrupt request can be generated by different kinds of error, and the two subnode interrupts controlled by the isnc and clisnc registers (see interrupt and pec descriptions). however, specific status flags which identify the type of error are implemented in the serial channels? control registers. the c165h provides a vectored interrupt system. in this system specific vector locations in the memory space are reserved for the reset, trap, and interrupt service functions. whenever a request occurs, the cpu branches to the location that is associated with the respective interrupt source. this allows direct identification of the source that caused the request. the only exceptions are the class b hardware traps, which all share the same interrupt vector. the status flags in the trap flag register (tfr) can then be used to determine which exception caused the trap. for the special software trap instruction, the vector address is specified by the operand field of the instruction, which is a seven bit trap number. the reserved vector locations build a jump table in the low end of the c165h?s address space (segment 0). the jump table is made up of the appropriate jump instructions that transfer control to the interrupt or trap service routines, which may be located anywhere within the address space. the entries of the jump table are located at the lowest addresses in code segment 0 of the address space. each entry occupies 2 words, except for the reset vector and the hardware trap vectors, which occupy 4 or 8 words. the table below lists all sources that are capable of requesting interrupt or pec service in the c165h, the associated interrupt vectors, their locations, their trap numbers and the sfr addresses of associated interrupt control registers. it also lists the mnemonics of the corresponding interrupt enable flags. the mnemonics are composed of a part that specifies the respective source, followed by a part that specifies their function (ie=interrupt enable flag). the same composition is used for the mnemonics of according interrupt request flags (ir=interrupt request flag; example: cc0ir belongs to interrupt source cc0int) and for the names of according interrupt control registers (ic=interrupt control; example: cc0ic) which are not included in table 14 .
c165h interrupt and trap functions data sheet 94 2001-04-19 p r e l i m i n a r y - exc er p t - table 14 c165h interrupts and pec service requests nr. source of interrupt or pec service request interrupt name enable flag vector location trap number sfr hex addr irq(0) gpt timer 2 t2int t2ie 00?0088 h 22 h / 34 d ff60 irq(1) gpt timer 3 t3int t3ie 00?008c h 23 h / 35 d ff62 irq(2) gpt timer 4 t4int t4ie 00?0090 h 24 h / 36 d ff64 irq(3) gpt timer 5 t5int t5ie 00?0094 h 25 h / 37 d ff66 irq(4) gpt timer 6 t6int t6ie 00?0098 h 26 h / 38 d ff68 irq(5) gpt caprel register crint crie 00?009c h 27 h / 39 d ff6a irq(6) asc transmit s0tint s0tie 00?00a8 h 2a h / 42 d ff6c irq(7) asc receive s0rint s0rie 00?00ac h 2b h / 43 d ff6e irq(8) asc error s0eint s0eie 00?00b0 h 2c h / 44 d ff70 irq(9) asc transmit buffer s0tbint s0tbie 00?011c h 47 h / 71 d f19c irq(10) ssc transmit ssctint ssctie 00?00b4 h 2d h / 45 d ff72 irq(11) ssc receive sscrint sscrie 00?00b8 h 2e h / 46 d ff74 irq(12) ssc error ssceint ssceie 00?00bc h 2f h / 47 d ff76 irq(13) asc autobaud start abstint abstie 00?0118 h 46 h / 70 d f194 irq(14) asc autobaud end abendint abendie 00?0114 h 45 h / 69 d f18c irq(15) rrtc interrupt rtc_int rtcie 00?0110 h 44 h / 68 d f184 irq(16) udc setup usetint usetie 00?00f0 h 3c h / 60 d f178 irq(17) udc load config done ulcdint ulcdie 00?00ec h 3b h / 59 d f176 irq(18) udc suspend ussint ussie 00?00e8 h 3a h / 58 d f174 irq(19) udc suspend off ussoint ussoie 00?00e4 h 39 h / 57 d f172 irq(20) udc start of frame usofint usofie 00?00e0 h 38 h / 56 d f170 irq(21) udc config val ucfgvint ucfgvie 00?00dc h 37 h / 55 d f16e irq(22) udc txwr utxrint utxrie 00?00d8 h 36 h / 54 d f16c irq(23) udc rxrr urxrint urxrie 00?00d4 h 35 h / 53 d f16a irq(24) udc tx done7 utd7int utd7ie 00?00d0 h 34 h / 52 d f168 irq(25) udc tx done6 utd6int utd6ie 00?00cc h 33 h / 51 d f166
c165h interrupt and trap functions data sheet 95 2001-04-19 p r e l i m i n a r y - exc er pt - irq(26) udc tx done5 utd5int utd5ie 00?00c8 h 32 h / 50 d f164 irq(27) udc tx done4 utd4int utd4ie 00?00c4 h 31 h / 49 d f162 irq(28) udc tx done3 utd3int utd3ie 00?00c0 h 30 h / 48 d f160 irq(29) udc tx done2 utd2int utd2ie 00?005c h 17 h / 23 d ff86 irq(30) udc tx done1 utd1int utd1ie 00?0058 h 16 h / 22 d ff84 irq(31) udc tx done0 utd0int utd0ie 00?0054 h 15 h / 21 d ff82 irq(32) udc rx done7 urd7int urd7ie 00?0050 h 14 h / 20 d ff80 irq(33) udc rx done6 urd6int urd6ie 00?004c h 13 h / 19 d ff7e irq(34) udc rx done5 urd5int urd5ie 00?0048 h 12 h / 18 d ff7c irq(35) udc rx done4 urd4int urd4ie 00?0044 h 11 h / 17 d ff7a irq(36) udc rx done3 urd3int urd3ie 00?0040 h 10 h / 16 d ff78 irq(37) udc rx done2 urd2int urd2ie 00?0080 h 20 h / 32 d ff9c irq(38) udc rx done1 urd1int urd1ie 00?0084 h 21 h / 33 d ff9e irq(39) udc rx done0 urd0int urd0ie 00?00f4 h 3d h / 61 d f17a irq(40) reserved 00?00f8 h 3e h / 62 d f17c irq(41) reserved 00?00a0 h 28 h / 40 d ff98 irq(42) iom-2 i/o iomioint iomioie 00?00a4 h 29 h / 41 d ff9a irq(43) iom-2 channel0 tx iomc0tint iomc0tie 00?00fc h 3f h / 63 d f17e irq(44) iom-2 channel0 rx iomc0rint iomc0rie 00?0120 h 48 h / 72 d f182 irq(45) iom-2 channel1 tx iomc1tint iomc1tie 00?0124 h 49 h / 73 d f18a irq(46) iom-2 channel1 rx iomc1rint iomc1rie 00?0128 h 4a h / 74 d f192 irq(47) reserved 00?012c h 4b h / 75 d f19a firq(0) fast ext. interrupt ex0int ex0ie 00?0060 h 18 h / 24 d ff88 firq(1) fast ext. interrupt ex1int ex1ie 00?0064 h 19 h / 25 d ff8a firq(2) fast ext. interrupt ex2int ex2ie 00?0068 h 1a h / 26 d ff8c firq(3) fast ext. interrupt ex3int ex3ie 00?006c h 1b h / 27 d ff8e firq(4) fast ext. interrupt ex4int ex4ie 00?0070 h 1c h / 28 d ff90 firq(5) fast ext. interrupt ex5int ex5ie 00?0074 h 1d h / 29 d ff92 nr. source of interrupt or pec service request interrupt name enable flag vector location trap number sfr hex addr
c165h interrupt and trap functions data sheet 96 2001-04-19 p r e l i m i n a r y - exc er p t - note: 1. the x-bus interrupt xb(2), known from c16x device?s, is connected to the main interrupt node of the x-bus peripheral: iomioint (xb(2) and irq(42)). 2. each entry of the interrupt vector table provides space for two word instructions or one doubleword instruction. the respective vector location results from multiplying the trap number by 4 (4 bytes per entry). 3. one interrupt control register is provided for each interrupt node. all ic registers of the c165h can be found in the sfr list. table 15 lists the vector locations for hardware traps and the corresponding status flags in register tfr. it also lists the priorities of trap service for cases, where more than one trap condition might be detected within the same instruction. after any reset (hardware reset, software reset instruction srst, or reset by watchdog timer overflow) program execution starts at the reset vector at location 00?0000 h . reset conditions have priority over every other system activity and therefore have the highest priority (trap priority iii). software traps may be initiated to any vector location between 00?0000 h and 00?01fc h . a service routine entered via a software trap instruction is always executed on the current cpu priority level which is indicated in bit field ilvl in register psw. this means that routines entered via the software trap instruction can be interrupted by all hardware traps or higher level interrupt requests. firq(6) fast ext. interrupt ex6int ex6ie 00?0078 h 1e h / 30 d ff94 firq(7) fast ext. interrupt ex7int ex7ie 00?007c h 1f h / 31 d ff96 xb(0) udc txwr utxrint utxrie 00?0100 h 40 h / 64 d f186 xb(1) reserved 00?0104 h 41 h / 65 d f18e xb(2) iom-2 io iomioint iomioie 00?0108 h 42 h / 66 d f196 xb(3) internal pll lock / rtc xp3int xp3ie 00?010c h 43 h / 67 d f19e clisn interrupt clisnint clisnie 00?0130 h 4c h / 76 d ffa8 nr. source of interrupt or pec service request interrupt name enable flag vector location trap number sfr hex addr
c165h interrupt and trap functions data sheet 97 2001-04-19 p r e l i m i n a r y - exc er pt - table 15 hardware traps and vector locations normal interrupt processing and pec service during each instruction cycle one out of all sources which require pec or interrupt processing is selected according to its interrupt priority. this priority of interrupts and pec requests is programmable in two levels. each requesting source can be assigned to a specific priority. a second level (called ?group priority?) allows to specify an internal order for simultaneous requests from a group of different sources on the same priority level. at the end of each instruction cycle the one source request with the highest current priority will be determined by the interrupt system. this request will then be serviced, if its priority is higher than the current cpu priority in register psw. exception condition trap flag trap vector vector location trap number trap priority reset functions: hardware reset software reset watchdog timer overflow reset reset reset 00?0000 h 00?0000 h 00?0000 h 00 h 00 h 00 h iii iii iii class a hardware traps: non-maskable interrupt stack overflow stack underflow debug trap nmi stkof stkuf debug nmitrap stotrap stutrap debtrap 00?0008 h 00?0010 h 00?0018 h 00?0020 h 02 h 04 h 06 h 08 h ii ii ii ii class b hardware traps: undefined opcode protected instruction fault illegal word operand access illegal instruction access illegal external bus access undopc prtflt # illopa illina illbus btrap btrap btrap btrap btrap 00?0028 h 00?0028 h 00?0028 h 00?0028 h 00?0028 h 0a h 0a h 0a h 0a h 0a h i i i i i reserved [2c h ? 3c h ][0b h ? 0f h ] software traps trap instruction any [00?0000 h ? 00?01fc h ] in steps of 4 h any [00 h ? 7f h ] current cpu priority
c165h interrupt and trap functions data sheet 98 2001-04-19 p r e l i m i n a r y - exc er p t - interrupt system register description interrupt processing is controlled globally by register psw through a general interrupt enable bit (ien) and the cpu priority field (ilvl). additionally the different interrupt sources are controlled individually by their specific interrupt control registers (...ic). thus, the acceptance of requests by the cpu is determined by both the individual interrupt control registers and the psw. pec services are controlled by the respective peccx register and the source and destination pointers, which specify the task of the respective pec service channel. 6.2 interrupt control registers all interrupt control registers are organized identically. the lower 8 bits of an interrupt control register contain the complete interrupt status information of the associated source, which is required during one round of prioritization, the upper 8 bits of the respective register are reserved. all interrupt control registers are bit-addressable and all bits can be read or written via software. this allows each interrupt source to be programmed or modified with just one instruction. when accessing interrupt control registers through instructions which operate on word data types, their upper 8 bits (15...8) will return zeros, when read, and will discard written data. the layout of the interrupt control registers shown below applies to each xxic register, where xx stands for the mnemonic for the respective source.
c165h interrupt and trap functions data sheet 99 2001-04-19 p r e l i m i n a r y - exc er pt - xxic (yyyy h / zz h ) reset value: - - 00 h the interrupt request flag is set by hardware whenever a service request from the respective source occurs. it is cleared automatically upon entry into the interrupt service routine or upon a pec service. in the case of pec service the interrupt request flag remains set, if the count field in register peccx of the selected pec channel decrements to zero. this allows a normal cpu interrupt to respond to a completed pec block transfer. note: modifying the interrupt request flag via software causes the same effects as if it had been set or cleared by hardware. interrupt priority level and group level the four bits of bit field ilvl specify the priority level of a service request for the arbitration of simultaneous requests. the priority increases with the numerical value of ilvl, so 0000 b is the lowest and 1111 b is the highest priority level. when more than one interrupt request on a specific level gets active at the same time, the values in the respective bit fields glvl are used for second level arbitration to select one request for being serviced. again the group priority increases with the numerical value of glvl, so 00 b is the lowest and 11 b is the highest group priority. bit function glvl group level defines the internal order for simultaneous requests of the same priority. 3: highest group priority 0: lowest group priority ilvl interrupt priority level defines the priority level for the arbitration of requests. f h : highest priority level 0 h : lowest priority level xxie interrupt enable control bit (individually enables/disables a specific source) ?0?: interrupt request is disabled ?1?: interrupt request is enabled xxir interrupt request flag ?0?: no request pending ?1?: this source has raised an interrupt request 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw - - - - rw rw - - - - xxie xxir glvl ilvl
c165h interrupt and trap functions data sheet 100 2001-04-19 p r e l i m i n a r y - exc er p t - note: all interrupt request sources that are enabled and programmed to the same priority level must always be programmed to different group priorities. otherwise an incorrect interrupt vector will be generated. upon entry into the interrupt service routine, the priority level of the source that won the arbitration and who?s priority level is higher than the current cpu level, is copied into bit field ilvl of register psw after pushing the old psw contents on the stack. the interrupt system of the c165h allows nesting of up to 15 interrupt service routines of different priority levels (level 0 cannot be arbitrated). interrupt requests that are programmed to priority levels 15 or 14 (ie, ilvl=111x b ) will be serviced by the pec, unless the count field of the associated pecc register contains zero. in this case the request will instead be serviced by normal interrupt processing. interrupt requests that are programmed to priority levels 13 through 1 will always be serviced by normal interrupt processing. note: priority level 0000 b is the default level of the cpu. therefore a request on level 0 will never be serviced, because it can never interrupt the cpu. however, an enabled interrupt request on level 0000 b will terminate the c165h?s idle mode and reactivate the cpu. for interrupt requests which are to be serviced by the pec, the associated pec channel number is derived from the respective ilvl (lsb) and glvl (see figure below). so programming a source to priority level 15 (ilvl=1111 b ) selects the pec channel group 7...4, programming a source to priority level 14 (ilvl=1110 b ) selects the pec channel group 3...0. the actual pec channel number is then determined by the group priority field glvl. figure 20 priority levels and pec channels simultaneous requests for pec channels are prioritized according to the pec channel number, where channel 0 has lowest and channel 7 has highest priority. note: all sources that request pec service must be programmed to different pec channels. otherwise an incorrect pec channel may be activated. mcd02006 ilvl glvl pec channel interrupt control register pec control
c165h interrupt and trap functions data sheet 101 2001-04-19 p r e l i m i n a r y - exc er pt - the table below shows in a few examples, which action is executed with a given programming of an interrupt control register. table 16 programming example note: all requests on levels 13...1 cannot initiate pec transfers. they are always serviced by an interrupt service routine. no pecc register is associated and no count field is checked. interrupt control functions in the psw the processor status word (psw) is functionally divided into 2 parts: the lower byte of the psw basically represents the arithmetic status of the cpu, the upper byte of the psw controls the interrupt system of the c165h and the arbitration mechanism for the external bus interface. note: pipeline effects have to be considered when enabling/disabling interrupt requests via modifications of register psw (see chapter ?the central processing unit?). priority level type of service ilvl glvl count = 00h count 00 h 1 1 1 1 1 1 cpu interrupt, level 15, group priority 3 pec service, channel 7 1 1 1 1 1 0 cpu interrupt, level 15, group priority 2 pec service, channel 6 1 1 1 0 1 0 cpu interrupt, level 14, group priority 2 pec service, channel 2 1 1 0 1 1 0 cpu interrupt, level 13, group priority 2 cpu interrupt, level 13, group priority 2 0 0 0 1 1 1 cpu interrupt, level 1, group priority 3 cpu interrupt, level 1, group priority 3 0 0 0 1 0 0 cpu interrupt, level 1, group priority 0 cpu interrupt, level 1, group priority 0 0 0 0 0 x x no service! no service!
c165h interrupt and trap functions data sheet 102 2001-04-19 p r e l i m i n a r y - exc er p t - psw (ff10 h / 88 h ) sfr reset value: 0000 h cpu priority ilvl defines the current level for the operation of the cpu. this bit field reflects the priority level of the routine that is currently executed. upon entry into an interrupt service routine this bit field is updated with the priority level of the request that is being serviced. the psw is saved on the system stack before. the cpu level determines the minimum interrupt priority level that will be serviced. any request on the same or a lower level will not be acknowledged. the current cpu priority level may be adjusted via software to control which interrupt request sources will be acknowledged. pec transfers do not really interrupt the cpu, but rather ?steal? a single cycle, so pec services do not influence the ilvl field in the psw. hardware traps switch the cpu level to maximum priority (ie. 15) so no interrupt or pec requests will be acknowledged while an exception trap service routine is executed. note: the trap instruction does not change the cpu level, so software invoked trap service routines may be interrupted by higher requests. interrupt enable bit ien globally enables or disables pec operation and the acceptance of interrupts by the cpu. when ien is cleared, no interrupt requests are accepted by the cpu. when ien is set to '1', all interrupt sources, which have been individually enabled by the interrupt enable bits in their associated control registers, are globally enabled. note: traps are non-maskable and are therefore not affected by the ien bit. bit function n, c, v, z, e, mulip, usr0 cpu status flags (described in section ? the central processing unit ? ) define the current status of the cpu (alu, multiplication unit). hlden hold enable (enables external bus arbitration) 0: bus arbitration disabled, p6.7...p6.5 may be used for general purpose i/o 1: bus arbitration enabled, p6.7...p6.5 serve as breq , hlda , hold , resp. ilvl cpu priority level defines the current priority level for the cpu f h : highest priority level 0 h : lowest priority level ien interrupt enable control bit (globally enables/disables interrupt requests) ? 0 ? : interrupt requests are disabled ? 1 ? : interrupt requests are enabled hld en - mul ip usr0 n zc v e 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw - rw rw rw - rw - rw ien - - ilvl rw
c165h interrupt and trap functions data sheet 103 2001-04-19 p r e l i m i n a r y - exc er pt - 6.3 operation of the pec channels the c165h's peripheral event controller (pec) provides 8 pec service channels, which move a single byte or word. this is the fastest possible interrupt response and in many cases is sufficient to service the respective peripheral request (eg. serial channels, etc.). each channel is controlled by a dedicated pec channel counter/control register (peccx) and a pair of pointers for source (srcpx) and destination (dstpx) of the data transfer. the pecc registers control the action that is performed by the respective pec channel. note: for the peccx register description, please also refer to page 86 of sub- chapter "extended pec channel control". byte/word transfer bit bwt controls, if a byte or a word is moved during a pec service cycle. this selection controls the transferred data size and the increment step for the modified pointer. increment control field inc controls, if one of the pec pointers is incremented after the pec transfer. it is not possible to increment both pointers, however. if the pointers are not modified (inc=?00?), the respective channel will always move data from the same source to the same destination. note: the reserved combination ?11? is changed to ?10? by hardware. however, it is not recommended to use this combination. the pec transfer count field count controls the action of a respective pec channel, where the content of bit field count at the time the request is activated selects the action. count may allow a specified number of pec transfers, unlimited transfers or no pec service at all. the table below summarizes, how the count field itself, the interrupt requests flag ir and the pec channel action depends on the previous content of count. previous count modified count ir after pec service action of pec channel and comments ff h ff h ? 0 ? move a byte / word continuous transfer mode, ie. count is not modified fe h ..02 h fd h ..01 h ? 0 ? move a byte / word and decrement count 01 h 00 h ? 1 ? move a byte / word leave request flag set, which triggers another request 00 h 00 h ( ? 1 ? ) no action! activate interrupt service routine rather than pec channel.
c165h interrupt and trap functions data sheet 104 2001-04-19 p r e l i m i n a r y - exc er p t - the pec transfer counter allows to service a specified number of requests by the respective pec channel, and then (when count reaches 00 h ) activate the interrupt service routine, which is associated with the priority level. after each pec transfer the count field is decremented and the request flag is cleared to indicate that the request has been serviced. continuous transfers are selected by the value ff h in bit field count. in this case count is not modified and the respective pec channel services any request until it is disabled again. when count is decremented from 01 h to 00 h after a transfer, the request flag is not cleared, which generates another request from the same source. when count already contains the value 00 h , the respective pec channel remains idle and the associated interrupt service routine is activated instead. this allows to choose, if a level 15 or 14 request is to be serviced by the pec or by the interrupt service routine. note: pec transfers are only executed, if their priority level is higher than the cpu level, ie. only pec channels 7...4 are processed, while the cpu executes on level 14. all interrupt request sources that are enabled and programmed for pec service should use different channels. otherwise only one transfer will be performed for all simultaneous requests. when count is decremented to 00 h , and the cpu is to be interrupted, an incorrect interrupt vector will be generated. the source and destination pointers specifiy the locations between which the data is to be moved. a pair of pointers (srcpx and dstpx) is associated with each of the 8 pec channels. these pointers do not reside in specific sfrs, but are mapped into the internal ram of the c165h just below the bit-addressable area (see figure below). figure 21 mapping of pec pointers into the internal ram dstp7 00 ? fcfe h srcp7 00 ? fcfc h dstp6 00 ? fcfa h srcp6 00 ? fcf8 h dstp5 00 ? fcf6 h srcp5 00 ? fcf4 h dstp4 00 ? fcf2 h srcp4 00 ? fcf0 h dstp3 00 ? fcee h srcp3 00 ? fcec h dstp2 00 ? fcea h srcp2 00 ? fce8 h dstp1 00 ? fce6 h srcp1 00 ? fce4 h dstp0 00 ? fce2 h srcp0 00 ? fce0 h
c165h interrupt and trap functions data sheet 105 2001-04-19 p r e l i m i n a r y - exc er pt - pec data transfers do not use the data page pointers dpp3...dpp0, see also chapter 5.5, "pec - extension of functionality". the pec source and destination pointers are used as 16-bit intra-segment addresses within segment 0, so data can be transferred between any two locations within the first four data pages 3...0. the pointer locations for inactive pec channels may be used for general data storage. only the required pointers occupy ram locations. note: if word data transfer is selected for a specific pec channel (ie. bwt=?0?), the respective source and destination pointers must both contain a valid word address which points to an even byte boundary. otherwise the illegal word access trap will be invoked, when this channel is used. 6.4 prioritization of interrupt and pec service requests interrupt and pec service requests from all sources can be enabled, so they are arbitrated and serviced (if they win), or they may be disabled, so their requests are disregarded and not serviced. enabling and disabling interrupt requests may be done via three mechanisms: control bits allow to switch each individual source ?on? or ?off?, so it may generate a request or not. the control bits (xxie) are located in the respective interrupt control registers. all interrupt requests may be enabled or disabled generally via bit ien in register psw. this control bit is the ?main switch? that selects, if requests from any source are accepted or not. for a specific request to be arbitrated the respective source?s enable bit and the global enable bit must both be set. the priority level automatically selects a certain group of interrupt requests that will be acknowledged, disclosing all other requests. the priority level of the source that won the arbitration is compared against the cpu?s current level and the source is only serviced, if its level is higher than the current cpu level. changing the cpu level to a specific value via software blocks all requests on the same or a lower level. an interrupt source that is assigned to level 0 will be disabled and never be serviced. the atomic and extend instructions automatically disable all interrupt requests for the duration of the following 1...4 instructions. this is useful eg. for semaphore handling and does not require to re-enable the interrupt system after the unseparable instruction sequence (see chapter ?system programming?). interrupt class management an interrupt class covers a set of interrupt sources with the same importance, ie. the same priority from the system?s viewpoint. interrupts of the same class must not interrupt each other. the c165h supports this function with two features:
c165h interrupt and trap functions data sheet 106 2001-04-19 p r e l i m i n a r y - exc er p t - classes with up to 4 members can be established by using the same interrupt priority (ilvl) and assigning a dedicated group level (glvl) to each member. this functionality is built-in and handled automatically by the interrupt controller. classes with more than 4 members can be established by using a number of adjacent interrupt priorities (ilvl) and the respective group levels (4 per ilvl). each interrupt service routine within this class sets the cpu level to the highest interrupt priority within the class. all requests from the same or any lower level are blocked now, ie. no request of this class will be accepted. the example below establishes 3 interrupt classes which cover 2 or 3 interrupt priorities, depending on the number of members in a class. a level 6 interrupt disables all other sources in class 2 by changing the current cpu level to 8, which is the highest priority (ilvl) in class 2. class 1 requests or pec requests are still serviced in this case. the 19 interrupt sources (excluding pec requests) are so assigned to 3 classes of priority rather than to 7 different levels, as the hardware support would do.
c165h interrupt and trap functions data sheet 107 2001-04-19 p r e l i m i n a r y - exc er pt - table 17 software controlled interrupt classes (example) ilvl (priority) glvl interpretation 3210 15 pec service on up to 8 channels 14 13 12 x x x x interrupt class 1 5 sources on 2 levels 11 x 10 9 8 x x x x interrupt class 2 9 sources on 3 levels 7xxxx 6x 5 x x x x interrupt class 3 5 sources on 2 levels 4x 3 2 1 0 no service!
c165h interrupt and trap functions data sheet 108 2001-04-19 p r e l i m i n a r y - exc er p t - 6.5 saving the status during interrupt service before an interrupt request that has been arbitrated is actually serviced, the status of the current task is automatically saved on the system stack. the cpu status (psw) is saved along with the location, where the execution of the interrupted task is to be resumed after returning from the service routine. this return location is specified through the instruction pointer (ip) and, in case of a segmented memory model, the code segment pointer (csp). bit sgtdis in register syscon controls, how the return location is stored. the system stack receives the psw first, followed by the ip (unsegmented) or followed by csp and then ip (segmented mode). this optimizes the usage of the system stack, if segmentation is disabled. the cpu priority field (ilvl in psw) is updated with the priority of the interrupt request that is to be serviced, so the cpu now executes on the new level. if a multiplication or division was in progress at the time the interrupt request was acknowledged, bit mulip in register psw is set to ?1?. in this case the return location that is saved on the stack is not the next instruction in the instruction flow, but rather the multiply or divide instruction itself, as this instruction has been interrupted and will be completed after returning from the service routine. figure 22 task status saved on the system stack (unsegmented) psw system stack after interrupt entry interrupt entry system stack before a) b) sp high addresses low addresses -- -- -- sp ip -- mcd02226 c) interrupt entry system stack after (segmented) task interrupted status of csp psw ip sp
c165h interrupt and trap functions data sheet 109 2001-04-19 p r e l i m i n a r y - exc er pt - the interrupt request flag of the source that is being serviced is cleared. the ip is loaded with the vector associated with the requesting source (the csp is cleared in case of segmentation) and the first instruction of the service routine is fetched from the respective vector location, which is expected to branch to the service routine itself. the data page pointers and the context pointer are not affected. when the interrupt service routine is left (reti is executed), the status information is popped from the system stack in the reverse order, taking into account the value of bit sgtdis. context switching an interrupt service routine usually saves all the registers it uses on the stack, and restores them before returning. the more registers a routine uses, the more time is wasted with saving and restoring. the c165h allows to switch the complete bank of cpu registers (gprs) with a single instruction, so the service routine executes within its own, separate context. the instruction ?scxt cp, #new_bank? pushes the content of the context pointer (cp) on the system stack and loads cp with the immediate value ?new_bank?, which selects a new register bank. the service routine may now use its ?own registers?. this register bank is preserved, when the service routine terminates, ie. its contents are available on the next call. before returning (reti) the previous cp is simply popped from the system stack, which returns the registers to the original bank. note: the first instruction following the scxt instruction must not use a gpr. resources that are used by the interrupting program must eventually be saved and restored, eg. the dpps and the registers of the mul/div unit. 6.6 interrupt response times the interrupt response time defines the time from an interrupt request flag of an enabled interrupt source being set until the first instruction (i1) being fetched from the interrupt vector location. the basic interrupt response time for the c165h is 3 instruction cycles.
c165h interrupt and trap functions data sheet 110 2001-04-19 p r e l i m i n a r y - exc er p t - figure 23 pipeline diagram for interrupt response time all instructions in the pipeline including instruction n (during which the interrupt request flag is set) are completed before entering the service routine. the actual execution time for these instructions (eg. waitstates) therefore influences the interrupt response time. in the figure above the respective interrupt request flag is set in cycle 1 (fetching of instruction n). the indicated source wins the prioritization round (during cycle 2). in cycle 3 a trap instruction is injected into the decode stage of the pipeline, replacing instruction n+1 and clearing the source's interrupt request flag to '0'. cycle 4 completes the injected trap instruction (save psw, ip and csp, if segmented mode) and fetches the first instruction (i1) from the respective vector location. all instructions that entered the pipeline after setting of the interrupt request flag (n+1, n+2) will be executed after returning from the interrupt service routine. the minimum interrupt response time is 5 states (10 tcl). this requires program execution from the internal code memory, no external operand read requests and setting the interrupt request flag during the last state of an instruction cycle. when the interrupt request flag is set during the first state of an instruction cycle, the minimum interrupt response time under these conditions is 6 state times (12 tcl). the interrupt response time is increased by all delays of the instructions in the pipeline that are executed before entering the service routine (including n).  when internal hold conditions between instruction pairs n-2/n-1 or n-1/n occur, or instruction n explicitly writes to the psw or the sp, the minimum interrupt response time may be extended by 1 state time for each of these conditions.  when instruction n reads an operand from the internal code memory, or when n is a call, return, trap, or mov rn, [rm+ #data16] instruction, the minimum interrupt pipeline stage cycle 1 cycle 2 cycle 3 cycle 4 fetch n n + 1n + 2i1 decode n - 1 n trap (1) trap (2) execute n - 2 n - 1 n trap writeback n - 3 n - 2 n - 1 n interrupt response time 1 0 ir-flag
c165h interrupt and trap functions data sheet 111 2001-04-19 p r e l i m i n a r y - exc er pt - response time may additionally be extended by 2 state times during internal code memory program execution.  in case instruction n reads the psw and instruction n-1 has an effect on the condition flags, the interrupt response time may additionally be extended by 2 state times. the worst case interrupt response time during internal code memory program execution adds to 12 state times (24 tcl). any reference to external locations increases the interrupt response time due to pipeline related access priorities. the following conditions have to be considered:  instruction fetch from an external location  operand read from an external location  result write-back to an external location depending on where the instructions, source and destination operands are located, there are a number of combinations. note, however, that only access conflicts contribute to the delay. a few examples illustrate these delays:  the worst case interrupt response time including external accesses will occur, when instructions n, n+1 and n+2 are executed out of external memory, instructions n-1 and n require external operand read accesses, instructions n-3 through n write back external operands, and the interrupt vector also points to an external location. in this case the interrupt response time is the time to perform 9 word bus accesses, because instruction i1 cannot be fetched via the external bus until all write, fetch and read requests of preceding instructions in the pipeline are terminated.  when the above example has the interrupt vector pointing into the internal code memory, the interrupt response time is 7 word bus accesses plus 2 states, because fetching of instruction i1 from internal code memory can start earlier.  when instructions n, n+1 and n+2 are executed out of external memory and the interrupt vector also points to an external location, but all operands for instructions n- 3 through n are in internal memory, then the interrupt response time is the time to perform 3 word bus accesses.  when the above example has the interrupt vector pointing into the internal code memory, the interrupt response time is 1 word bus access plus 4 states. after an interrupt service routine has been terminated by executing the reti instruction, and if further interrupts are pending, the next interrupt service routine will not be entered until at least two instruction cycles have been executed of the program that was interrupted. in most cases two instructions will be executed during this time. only one instruction will typically be executed, if the first instruction following the reti instruction is a branch instruction (without cache hit), or if it reads an operand from internal code memory, or if it is executed out of the internal ram. note: a bus access in this context includes all delays which can occur during an external bus cycle.
c165h interrupt and trap functions data sheet 112 2001-04-19 p r e l i m i n a r y - exc er p t - 6.7 pec response times the pec response time defines the time from an interrupt request flag of an enabled interrupt source being set until the pec data transfer being started. the basic pec response time for the c165h is 2 instruction cycles. figure 24 pipeline diagram for pec response time in figure 24 the respective interrupt request flag is set in cycle 1 (fetching of instruction n). the indicated source wins the prioritization round (during cycle 2). in cycle 3 a pec transfer ?instruction? is injected into the decode stage of the pipeline, suspending instruction n+1 and clearing the source's interrupt request flag to '0'. cycle 4 completes the injected pec transfer and resumes the execution of instruction n+1. all instructions that entered the pipeline after setting of the interrupt request flag (n+1, n+2) will be executed after the pec data transfer. note: when instruction n reads any of the pec control registers pecc7...pecc0, while a pec request wins the current round of prioritization, this round is repeated and the pec data transfer is started one cycle later. the minimum pec response time is 3 states (6 tcl). this requires program execution from the internal code memory, no external operand read requests and setting the interrupt request flag during the last state of an instruction cycle. when the interrupt request flag is set during the first state of an instruction cycle, the minimum pec response time under these conditions is 4 state times (8 tcl). the pec response time is increased by all delays of the instructions in the pipeline that are executed before starting the data transfer (including n). pipeline stage cycle 1 cycle 2 cycle 3 cycle 4 fetchn n + 1n + 2n + 2 decode n - 1 n pec n + 1 execute n - 2 n - 1 n pec writeback n - 3 n - 2 n - 1 n pec response time 1 0 ir-flag
c165h interrupt and trap functions data sheet 113 2001-04-19 p r e l i m i n a r y - exc er pt -  when internal hold conditions between instruction pairs n-2/n-1 or n-1/n occur, the minimum pec response time may be extended by 1 state time for each of these conditions.  when instruction n reads an operand from the internal code memory, or when n is a call, return, trap, or mov rn, [rm+ #data16] instruction, the minimum pec response time may additionally be extended by 2 state times during internal code memory program execution.  in case instruction n reads the psw and instruction n-1 has an effect on the condition flags, the pec response time may additionally be extended by 2 state times.  the worst case pec response time during internal code memory program execution adds to 9 state times (18 tcl). any reference to external locations increases the pec response time due to pipeline related access priorities. the following conditions have to be considered:  instruction fetch from an external location  operand read from an external location  result write-back to an external location depending on where the instructions, source and destination operands are located, there are a number of combinations. note, however, that only access conflicts contribute to the delay. a few examples illustrate these delays:  the worst case interrupt response time including external accesses will occur, when instructions n and n+1 are executed out of external memory, instructions n-1 and n require external operand read accesses and instructions n-3, n-2 and n-1 write back external operands. in this case the pec response time is the time to perform 7 word bus accesses.  when instructions n and n+1 are executed out of external memory, but all operands for instructions n-3 through n-1 are in internal memory, then the pec response time is the time to perform 1 word bus access plus 2 state times. once a request for pec service has been acknowledged by the cpu, the execution of the next instruction is delayed by 2 state times plus the additional time it might take to fetch the source operand from internal code memory or external memory and to write the destination operand over the external bus in an external program environment. note: a bus access in this context includes all delays which can occur during an external bus cycle. 6.8 external interrupts although the c165h has no dedicated intr input pins, it provides many possibilities to react on external asynchronous events by using a number of i/o lines for interrupt input. the interrupt function may either be combined with the pin?s main function or may be used instead of it, ie. if the main pin function is not required.
c165h interrupt and trap functions data sheet 114 2001-04-19 p r e l i m i n a r y - exc er p t - interrupt signals may be connected to:  ex7in...ex0in, the fast external interrupt input pins,  t4in, t2in, the timer input pins, for each of these pins either a positive, a negative, or both a positive and a negative external transition can be selected to cause an interrupt or pec service request. the edge selection is performed in the control register of the peripheral device associated with the respective port pin. the peripheral must be programmed to a specific operating mode to allow generation of an interrupt by the external signal. the priority of the interrupt request is determined by the interrupt control register of the respective peripheral interrupt source, and the interrupt vector of this source will be used to service the external interrupt request. note: in order to use any of the listed pins as external interrupt input, it must be switched to input mode via its direction control bit dpx.y in the respective port direction control register dpx. pins t2in or t4in can be used as external interrupt input pins when the associated auxiliary timer t2 or t4 in block gpt1 is configured for capture mode. this mode is selected by programming the mode control fields t2m or t4m in control registers t2con or t4con to 101 b . the active edge of the external input signal is determined by bit fields t2i or t4i. when these fields are programmed to x01 b , interrupt request flags t2ir or t4ir in registers t2ic or t4ic will be set on a positive external transition at pins t2in or t4in, respectively. when t2i or t4i are programmed to x10 b , then a negative external transition will set the corresponding request flag. when t2i or t4i are programmed to x11 b , both a positive and a negative transition will set the request flag. in all three cases, the contents of the core timer t3 will be captured into the auxiliary timer registers t2 or t4 based on the transition at pins t2in or t4in. when the interrupt enable bits t2ie or t4ie are set, a pec request or an interrupt request for vector t2int or t4int will be generated. note: the non-maskable interrupt input pin nmi and the reset input rstin provide another possibility for the cpu to react on an external input signal. nmi and rstin are dedicated input pins, which cause hardware traps. table 18 pins to be used as external interrupt inputs port pin original function control register p2.7-0/ex7-0in fast external interrupt input pin exicon p3.7/t2in auxiliary timer t2 input pin t2con p3.5/t4in auxiliary timer t4 input pin t4con
c165h interrupt and trap functions data sheet 115 2001-04-19 p r e l i m i n a r y - exc er pt - 6.8.1 fast external interrupts the input pins that may be used for external interrupts are sampled every 16 tcl, ie. external events are scanned and detected in timeframes of 16 tcl. the c165h provides 8 external interrupt inputs that are sampled every 2 tcl, so external events are captured faster than with standard interrupt inputs. the pins of port 2 (p2.7...p2.0) can individually be programmed to this fast interrupt mode, where also the trigger transition (rising, falling or both) can be selected. the external interrupt control register exicon controls this feature for all 8 pins. exicon (f1c0 h / e0 h ) esfr reset value: 0000 h note: 1. the fast external interrupt inputs are sampled every 2 tcl. the interrupt request arbitration and processing, however, is executed every 8 tcl. 2. in sleep mode, no clock is available. therefore sampling is performed with asynchronous structures. 3. in sleep mode fast external interrupts as well as the nmi input are controlled for spike suppression in the system control block. input signals shorter than 10 ns are suppressed, detection is guaranteed for minimum 150 ns input signals. 6.8.2 external interrupt source control fast external interrupts may also have interrupt sources selected from other peripherals. this function is very advantageous in slow down mode or in sleep mode, if for example the ssc interface shall be used to wake-up the system. the register exisel is used to switch the receive inputs of the serial interfaces to the fast external interrupts, in order to detect incomming messages in case of disabled serial interface modules. the exisel register is defined as follows: bit function exixes external interrupt x edge selection field (x=7...0) 0 0: fast external interrupts disabled: standard mode 0 1: interrupt on positive edge (rising) 1 0: interrupt on negative edge (falling) 1 1: interrupt on any edge (rising or falling) 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw exi2es exi0es exi1es rw rw rw exi7es exi5es exi6es rw rw exi3es exi4es
c165h interrupt and trap functions data sheet 116 2001-04-19 p r e l i m i n a r y - exc er p t - exisel (f1da h / ed h ) esfr-breset value: 0000 h bit function exi0ss 0 0: input from default pin. must be set to ?00?. 0 1: not allowed. 1 0: not allowed. 1 1: not allowed. exi1ss 0 0: input from default pin.must be set to ?00?. 0 1: not allowed. 1 0: not allowed. 1 1: not allowed. exi2ss 0 0: input from default pin. 0 1: input from alternate source asc_rxd @ p3.11. 1 0: input from default pin ored with alternate source asc_rxd @ p3.11. 1 1: input from default pin anded with alternate source asc_rxd @ p3.11. exi3ss 0 0: input from default pin. 0 1: input from alternate source ssc_rxd @ p3.9. 1 0: input from default pin ored with alternate source ssc_rxd @ p3.9. 1 1: input from default pin anded with alternate source ssc_rxd @ p3.9. exi4ss 0 0: input from default pin. 0 1: input from alternate source ssc_sclk @ p3.13. 1 0: input from default pin ored with alternate source ssc_sclk @ p3.13. 1 1: input from default pin anded with alternate source ssc_sclk @ p3.13. exi5ss 0 0: input from default pin. must be set to ?00? 0 1: not allowed. 1 0: not allowed. 1 1: not allowed. exi6ss 0 0: input from default pin. 0 1: input from alternate source iom-2 @ dcl. 1 0: input from default pin ored with alternate source iom-2 @ dcl. 1 1: input from default pin anded with alternate source iom-2 @ dcl. exi7ss 0 0: not allowed. 0 1: input from source rtc_int. 1 0: not allowed. 1 1: not allowed. 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw exi2ss 00 00 rw rw rw 01 exi5ss exi6ss rw rw exi3ss exi4ss
c165h interrupt and trap functions data sheet 117 2001-04-19 p r e l i m i n a r y - exc er pt - 6.8.3 interrupt subnode control the rtc (real time clock) interrupt t14int and the pll/owd interrupt share one interrupt node, the xper3 interrupt node. in order to enable the interrupt handler to determine the source of that shared interrupt request, the subnode interrupt control register isnc is provided. the separate interrupt request and enable flags of register isnc (see below) for the pll (pllir, pllie) as well as for the rtc (t14ir, t14ie) are used as shown in figure 25 . figure 25 interrupt subnode control for pll / rtc interrupts note: the interrupt service routine must clear the ir flag in register isnc manually. otherwise no further interrupts can be detected. all request flags are bit protected. diff. circuit isnc & pulse generation t14 pllint diff. circuit t14int & ie t14 ir 1) pll ie pll ir 1) 1 int
c165h interrupt and trap functions data sheet 118 2001-04-19 p r e l i m i n a r y - exc er p t - the isnc register is defined as follows: 6.8.4 the interrupt control register the interrupt control registers listed below (fei7ic..fei0ic) control the fast external interrupts of the c165h. isnc (f1de h / ef h ) esfr-breset value : 0000 h 1514131211109876543210 pll ie pll ir rtc t14 ie rtc t14 ir bit function t14ir t14 overflow interrupt request flag ?0?: no request pending ?1?: this source has raised an interrupt request t14ie t14 overflow interrupt enable control bit ?0?: interrupt request is disabled ?1?: interrupt request is enabled pllir pll interrupt request flag ?0?: no request pending ?1?: this source has raised an interrupt request pllie pll interrupt enable control bit ?0?: interrupt request is disabled ?1?: interrupt request is enabled
c165h interrupt and trap functions data sheet 119 2001-04-19 p r e l i m i n a r y - exc er pt - feixic (see table) sfr reset value: - - 00 hh note: please refer to the general interrupt control register description for an explanation of the control fields. table 19 fast external interrupt control register addresses 6.9 trap functions traps interrupt the current execution similar to standard interrupts. however, trap functions offer the possibility to bypass the interrupt system's prioritization process in cases where immediate system reaction is required. trap functions are not maskable and always have priority over interrupt requests on any priority level. the c165h provides two different kinds of trapping mechanisms. hardware traps are triggered by events that occur during program execution (eg. illegal access or undefined opcode), software traps are initiated via an instruction within the current execution flow. software traps the trap instruction is used to cause a software call to an interrupt service routine. the trap number that is specified in the operand field of the trap instruction determines which vector location in the address range from 00?0000 h through 00?01fc h will be branched to. executing a trap instruction causes a similar effect as if an interrupt at the same vector had occurred. psw, csp (in segmentation mode), and ip are pushed on the internal system stack and a jump is taken to the specified vector location. when segmentation is enabled and a trap is executed, the csp for the trap service routine is set to code segment 0. no interrupt request flags are affected by the trap instruction. register address external interrupt fei0ic ff88 h / c4 h ex0in fei1ic ff8a h / c5 h ex1in fei2ic ff8c h / c6 h ex2in fei3ic ff8e h / c7 h ex3in fei4ic ff90 h / c8 h ex4in fei5ic ff92 h / c9 h ex5in fei6ic ff94 h / ca h ex6in fei7ic ff96 h / cb h ex7in 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw - - - - rw rw - - - - feix ie feix ir ilvl glvl
c165h interrupt and trap functions data sheet 120 2001-04-19 p r e l i m i n a r y - exc er p t - the interrupt service routine called by a trap instruction must be terminated with a reti (return from interrupt) instruction to ensure correct operation. note: the cpu level in register psw is not modified by the trap instruction, so the service routine is executed on the same priority level from which it was invoked. therefore, the service routine entered by the trap instruction can be interrupted by other traps or higher priority interrupts, other than when triggered by a hardware trap. hardware traps hardware traps are issued by faults or specific system states that occur during runtime of a program (not identified at assembly time). a hardware trap may also be triggered intentionally, eg. to emulate additional instructions by generating an illegal opcode trap. the c165h distinguishes eight different hardware trap functions. when a hardware trap condition has been detected, the cpu branches to the trap vector location for the respective trap condition. depending on the trap condition, the instruction which caused the trap is either completed or cancelled (ie. it has no effect on the system state) before the trap handling routine is entered. hardware traps are non-maskable and always have priority over every other cpu activity. if several hardware trap conditions are detected within the same instruction cycle, the highest priority trap is serviced (see table in section ?interrupt system structure?). psw, csp (in segmentation mode), and ip are pushed on the internal system stack and the cpu level in register psw is set to the highest possible priority level (ie. level 15), disabling all interrupts. the csp is set to code segment zero, if segmentation is enabled. a trap service routine must be terminated with the reti instruction. the eight hardware trap functions of the c165h are divided into two classes: class a traps are  external non-maskable interrupt (nmi )  stack overflow  stack underflow trap these traps share the same trap priority, but have an individual vector address. class b traps are  undefined opcode  protection fault  illegal word operand access  illegal instruction access  illegal external bus access trap these traps share the same trap priority, and the same vector address. the bit-addressable trap flag register (tfr) allows a trap service routine to identify the kind of trap which caused the exception. each trap function is indicated by a separate
c165h interrupt and trap functions data sheet 121 2001-04-19 p r e l i m i n a r y - exc er pt - request flag. when a hardware trap occurs, the corresponding request flag in register tfr is set to '1'. tfr (ffac h / d6 h ) sfr reset value: 0000 h note: the trap service routine must clear the respective trap flag, otherwise a new trap will be requested after exiting the service routine. setting a trap request flag by software causes the same effects as if it had been set by hardware. the reset functions (hardware, software, watchdog) may be regarded as a type of trap. reset functions have the highest system priority (trap priority iii). class a traps have the second highest priority (trap priority ii), on the 3rd rank are class b traps, so a class a trap can interrupt a class b trap. if more than one class a trap occur at a time, they are prioritized internally, with the nmi trap on the highest and the stack underflow trap on the lowest priority. all class b traps have the same trap priority (trap priority i). when several class b traps get active at a time, the corresponding flags in the tfr register are set and the trap service routine is entered. since all class b traps have the same vector, the priority of service of simultaneously occurring class b traps is determined by software in the trap service routine. bit function illbus illegal external bus access flag an external access has been attempted with no external bus defined. illina illegal instruction access flag a branch to an odd address has been attempted. illopa illegal word operand access flag a word operand access (read or write) to an odd address has been attempted. prtflt protection fault flag a protected instruction with an illegal format has been detected. undopc undefined opcode flag the currently decoded instruction has no valid c165h opcode. stkuf stack underflow flag the current stack pointer value exceeds the content of register stkun. stkof stack overflow flag the current stack pointer value falls below the content of register stkov. nmi non maskable interrupt flag a negative transition (falling edge) has been detected on pin nmi . nmi 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw - - - - rw - - - stk uf ill bus ill ina ill opa prt flt und opc stk of - - - - - - - - - rw rw
c165h interrupt and trap functions data sheet 122 2001-04-19 p r e l i m i n a r y - exc er p t - a class a trap occurring during the execution of a class b trap service routine will be serviced immediately. during the execution of a class a trap service routine, however, any class b trap occurring will not be serviced until the class a trap service routine is exited with a reti instruction. in this case, the occurrence of the class b trap condition is stored in the tfr register, but the ip value of the instruction which caused this trap is lost. in the case where e.g. an undefined opcode trap (class b) occurs simultaneously with an nmi trap (class a), both the nmi and the undopc flag is set, the ip of the instruction with the undefined opcode is pushed onto the system stack, but the nmi trap is executed. after return from the nmi service routine, the ip is popped from the stack and immediately pushed again because of the pending undopc trap. external nmi trap whenever a high to low transition on the dedicated external nmi pin (non-maskable interrupt) is detected, the nmi flag in register tfr is set and the cpu will enter the nmi trap routine. the ip value pushed on the system stack is the address of the instruction following the one after which normal processing was interrupted by the nmi trap. stack overflow trap whenever the stack pointer is decremented to a value which is less than the value in the stack overflow register stkov, the stkof flag in register tfr is set and the cpu will enter the stack overflow trap routine. which ip value will be pushed onto the system stack depends on which operation caused the decrement of the sp. when an implicit decrement of the sp is made through a push or call instruction, or upon interrupt or trap entry, the ip value pushed is the address of the following instruction. when the sp is decremented by a subtract instruction, the ip value pushed represents the address of the instruction after the instruction following the subtract instruction. for recovery from stack overflow it must be ensured that there is enough excess space on the stack for saving the current system state (psw, ip, in segmented mode also csp) twice. otherwise, a system reset should be generated. stack underflow trap whenever the stack pointer is incremented to a value which is greater than the value in the stack underflow register stkun, the stkuf flag is set in register tfr and the cpu will enter the stack underflow trap routine. again, which ip value will be pushed onto the system stack depends on which operation caused the increment of the sp. when an implicit increment of the sp is made through a pop or return instruction, the ip value pushed is the address of the following instruction. when the sp is incremented by an add instruction, the pushed ip value represents the address of the instruction after the instruction following the add instruction.
c165h interrupt and trap functions data sheet 123 2001-04-19 p r e l i m i n a r y - exc er pt - undefined opcode trap when the instruction currently decoded by the cpu does not contain a valid c165h opcode, the undopc flag is set in register tfr and the cpu enters the undefined opcode trap routine. the ip value pushed onto the system stack is the address of the instruction that caused the trap. this can be used to emulate unimplemented instructions. the trap service routine can examine the faulting instruction to decode operands for unimplemented opcodes based on the stacked ip. in order to resume processing, the stacked ip value must be incremented by the size of the undefined instruction, which is determined by the user, before a reti instruction is executed. protection fault trap whenever one of the special protected instructions is executed where the opcode of that instruction is not repeated twice in the second word of the instruction and the byte following the opcode is not the complement of the opcode, the prtflt flag in register tfr is set and the cpu enters the protection fault trap routine. the protected instructions include diswdt, einit, idle, pwrdn, srst, and srvwdt. the ip value pushed onto the system stack for the protection fault trap is the address of the instruction that caused the trap. illegal word operand access trap whenever a word operand read or write access is attempted to an odd byte address, the illopa flag in register tfr is set and the cpu enters the illegal word operand access trap routine. the ip value pushed onto the system stack is the address of the instruction following the one which caused the trap. illegal instruction access trap whenever a branch is made to an odd byte address, the illina flag in register tfr is set and the cpu enters the illegal instruction access trap routine. the ip value pushed onto the system stack is the illegal odd target address of the branch instruction. illegal external bus access trap whenever the cpu requests an external instruction fetch, data read or data write, and no external bus configuration has been specified, the illbus flag in register tfr is set and the cpu enters the illegal bus access trap routine. the ip value pushed onto the system stack is the address of the instruction following the one which caused the trap.
c165h parallel ports data sheet 124 2001-04-19 p r e l i m i n a r y - exc er p t - 7 parallel ports in order to accept or generate single external control signals or parallel data, the c165h provides up to 72 parallel i/o lines. the c165h features port 0 (inculdes 8 bit p0h and 8 bit p0l), port 1 (8 bit p1h and 8 bit p1l), port 2 (8 bit), port 3 (11 bit), port 4 (7 bit), port 6 (8 bit) and port 7 (6 bit). these port lines may be used for general purpose input/output controlled via software or may be used implicitly by c165h?s integrated peripherals or the external bus controller. all port lines are bit addressable, and all input/output lines are individually (bit-wise) programmable as inputs or outputs via direction registers. the i/o ports are true bidirectional ports which are switched to high impedance state when configured as inputs. the output drivers of the i/o ports (p0h, p1, p2, p3, p4, p6, p7) can be configured (pin by pin) for push/pull operation or open-drain operation via control registers. the logic level of a pin is clocked into the input latch once per state time, regardless whether the port is configured for input or output. a write operation to a port pin configured as an input (dpx.y = ?0?) causes the value to be written into the port output latch, while a read operation returns the latched state of the pin itself. a read-modify-write operation reads the value of the pin, modifies it, and writes it back to the output latch. writing to a pin configured as an output (dpx.y=?1?) causes the output latch and the pin to have the written value, since the output buffer is enabled. reading this pin returns the value of the output latch. a read-modify-write operation reads the value of the output latch, modifies it, and writes it back to the output latch, thus also modifying the level at the pin.
c165h parallel ports data sheet 125 2001-04-19 p r e l i m i n a r y - exc er pt - figure 26 sfrs and pins associated with the parallel ports in the c165h certain ports provide open drain control, which allows to switch the output driver of a port pin from a push/pull configuration to an open drain configuration. in push/ pull mode a port output driver has an upper and a lower transistor, thus it can actively drive the line either to a high or a low level. in open drain mode the upper transistor is always switched off, and the output driver can only actively drive the line to a low level. when writing a ?1? to the port latch, the lower transistor is switched off and the output enters a high-impedance state. the high level must then be provided by an external pullup device. with this feature, it is possible to connect several port pins together to a wired-and configuration, saving external glue logic and/or additional software overhead for enabling/disabling output signals. this feature is implemented for all ports except p0l, and is controlled through the respective open drain control registers odpx. these registers allow the individual bit- wise selection of the open drain mode for each port line. if the respective control bit odpx.y is ?0? (default after reset), the output driver is in the push/pull mode. if odpx.y is ?1?, the open drain configuration is selected. note that all odpx registers are located in the esfr space. odp2 odp7 odp3 odp1l odp1h odp4 odp6 odp0h dp2 dp3 dp7 dp0l dp0h dp4 dp1h dp1l dp6 p2 p3 p7 p0l p0h p4 p1l p1h p6 data input / output registers direction control registers open drain control registers pxpudsel: p0l, p0h, p1l, p1h, p2, p3, p4, p6, p7 pxpuden: p0l, p0h, p1l, p1h, p2, p3, p4, p6, p7 pxphen: p0l, p0h, p1l, p1h, p2, p3, p4, p6, p7 pull up/down control registers
c165h parallel ports data sheet 126 2001-04-19 p r e l i m i n a r y - exc er p t - figure 27 output drivers in push/pull mode and in open drain mode alternate port functions each port line has one programmable alternate input or output function associated. port0 and port1 may be used as the address and data lines when accessing external memory. port 2 is used for fast external interrupt inputs. port 3 includes alternate input/output functions of timers, serial interfaces, the optional bus control signal bhe /wrh and the system clock output (clkout). port 4 outputs the additional segment address bits a22/a19/a17...a16 in systems where more than 64 kbytes of memory are to be accessed directly. port 6 provides the optional chip select outputs and the bus arbitration lines. port 7 is used for general purpose i/os. if an alternate output function of a pin is to be used, the direction of this pin must be programmed for output (dpx.y=?1?), except for some signals that are used directly after reset and are configured automatically. otherwise the pin remains in the high-impedance state and is not effected by the alternate output function. the respective port latch should hold a ?1?, because its output is anded with the alternate output data. note: dp0l and, if a 16 bit external xbus data bus is used, also dp0h must be ?0? as long as the xbus is active. if an alternate input function of a pin is used, the direction of the pin must be programmed for input (dpx.y=?0?) if an external device is driving the pin. the input direction is the default after reset. if no external device is connected to the pin, however, one can also set the direction for this pin to output. in this case, the pin reflects the state of the port output latch. thus, the alternate input function reads the value stored in the port output latch. this can be used for testing purposes to allow a software trigger of an alternate input function by writing to the port output latch. mcs01975 open drain output driver external pullup q push/pull output driver q pin pin
c165h parallel ports data sheet 127 2001-04-19 p r e l i m i n a r y - exc er pt - on most of the port lines, the user software is responsible for setting the proper direction when using an alternate input or output function of a pin. this is done by setting or clearing the direction control bit dpx.y of the pin before enabling the alternate function. there are port lines, however, where the direction of the port line is switched automatically. for instance, in the multiplexed external bus modes of port0, the direction must be switched several times for an instruction fetch in order to output the addresses and to input the data. obviously, this cannot be done through instructions. in these cases, the direction of the port line is switched automatically by hardware if the alternate function of such a pin is enabled. note: in this case, make sure dp0 is set to ?0? signal. to determine the appropriate level of the port output latches, check how the alternate data output is combined with the respective port latch output. there is one basic structure for all port lines with only an alternate input function. port lines with only an alternate output function, however, have different structures due to the way the direction of the pin is switched and depending on whether the pin is accessible by the user software or not in the alternate function mode. all port lines that are not used for these alternate functions may be used as general purpose i/o lines. when using port pins for general purpose output, the initial output value should be written to the port latch prior to enabling the output drivers, in order to avoid undesired transitions on the output pins. this applies to single pins as well as to pin groups (see examples below). output_enable_single_pin: bset p4.0 ;initial output level is ?high? bset dp4.0 ;switch on the output driver output_enable_pin_group: bfldl p4, #05h, #05h ;initial output level is ?high? bfldl dp4, #05h, #05h ;switch on the output drivers each of these ports and the alternate input and output functions are described in detail in the following subsections. 7.1 port0 the two 8-bit ports p0h and p0l represent the higher and lower part of port0, respectively. both halfs of port0 can be written (eg. via a pec transfer) without effecting the other half.
c165h parallel ports data sheet 128 2001-04-19 p r e l i m i n a r y - exc er p t - if this port is used for general purpose i/o, the direction of each line can be configured via the corresponding direction registers dp0h and dp0l. each port line of port0h can be switched into push/pull or open drain mode via the open drain control register odp0h. for port pins configured as input (via dp0x or alternate function), an internal pull transistor is connected to the pad if register p0xpuden = ?1?, no matter whether the c165h is in normal operation mode or in power down mode. either pulldown transistor or pullup transistor will be selected via p0xpudsel. for port pins configured as output, the internal pull transistors are always disabled. the output driver is disabled in power down mode unless p0xphen = ?1?. after reset, p0xpuden and p0xpudsel are set to high signal, thereby providing the default reset configuration 1111 h to the c165h during reset. note: while this feature allows the user to start the c165h after reset in default configuration without external pull devices, the default configuration may be overwritten by stronger external pulldown devices. in this case, software should disable the internal pull?s after reset (see also next chapter ?alternate function?).
c165h parallel ports data sheet 129 2001-04-19 p r e l i m i n a r y - exc er pt - p0l (ff00 h / 80 h ) sfr reset value: - - 00 h p0h (ff02 h / 81 h ) sfr reset value: - - 00 h dp0l (f100 h / 80 h ) esfr reset value: - - 00 h dp0h (f102 h / 81 h ) esfr reset value: - - 00 h bit function p0x.y port data register p0h or p0l bit y bit function dp0x.y port direction register dp0h or dp0l bit y dp0x.y = 0: port line p0x.y is an input (high-impedance) dp0x.y = 1: port line p0x.y is an output 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p0l.0 p0l.1 p0l.2 p0l.3 p0l.4 p0l.5 p0l.6 p0l.7 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p0h.0 p0h.1 p0h.2 p0h.3 p0h.4 p0h.5 p0h.6 p0h.7 dp0l .0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - dp0l .7 dp0l .6 dp0l .5 dp0l .4 dp0l .3 dp0l .2 dp0l .1 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - dp0h .7 dp0h .6 dp0h .5 dp0h .4 dp0h .3 dp0h .2 dp0h .1 dp0h .0
c165h parallel ports data sheet 130 2001-04-19 p r e l i m i n a r y - exc er p t - odp0h (fe22 h / 11 h ) sfr reset value: - - 00 h p0lpudsel (fe60 h / 30 h ) sfr reset value: - - ff h p0hpudsel (fe62 h / 31 h ) sfr reset value: - - ff h bit function odp0h.y port0h open drain control register bit y odp0h.y = 0: port line p0h.y output driver in push/pull mode odp0h.y = 1: port line p0h.y output driver in open drain mode bit function p0xpudsel.y pulldown/pullup selection p0xpudsel.y = 0: internal programmable pulldown transistor is selected p0xpudsel.y = 1: internal programmable pullup transistor is selected 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - odp0 h.7 odp0 h.6 odp0 h.5 odp0 h.4 odp0 h.3 odp0 h.2 odp0 h.1 odp0 h.0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p0l pud sel.7 p0l pud sel.6 p0l pud sel.5 p0l pud sel.4 p0l pud sel.3 p0l pud sel.2 p0l pud sel.1 p0l pud sel.0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p0h pud sel.7 p0h pud sel.6 p0h pud sel.5 p0h pud sel.4 p0h pud sel.3 p0h pud sel.2 p0h pud sel.1 p0h pud sel.0
c165h parallel ports data sheet 131 2001-04-19 p r e l i m i n a r y - exc er pt - p0lpuden (fe64 h / 32 h ) sfr reset value: - - ff h p0hpuden (fe66 h / 33 h ) sfr reset value: - - ff h p0lphen (fe68 h / 34 h ) sfr reset value: - - 00 h p0hphen (fe6a h / 35 h ) sfr reset value: - - 00 h bit function p0xpuden.y pulldown/pullup enable p0xpuden.y = 0: internal programmable pull transistor is disabled p0xpuden.y = 1: internal programmable pull transistor is enabled bit function p0xphen.y output driver enable in power down mode p0xphen.y = 0: output driver is disabled in power down mode p0xphen.y = 1: output driver is enabled in power down mode 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p0l pud en.7 p0l pud en.6 p0l pud en.5 p0l pud en.4 p0l pud en.3 p0l pud en.2 p0l pud en.1 p0l pud en.0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p0h pud en.7 p0h pud en.6 p0h pud en.5 p0h pud en.4 p0h pud en.3 p0h pud en.2 p0h pud en.1 p0h pud en.0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p0l phen .7 p0l phen .6 p0l phen .5 p0l phen .4 p0l phen .3 p0l phen .2 p0l phen .1 p0l phen .0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p0h phen .7 p0h phen .6 p0h phen .5 p0h phen .4 p0h phen .3 p0h phen .2 p0h phen .1 p0h phen .0
c165h parallel ports data sheet 132 2001-04-19 p r e l i m i n a r y - exc er p t - 7.1.1 alternate functions of port0 when an external bus is enabled, port0 is used as data bus or address/data bus. note that an external 8-bit demultiplexed bus only uses p0l, while p0h is free for i/o (provided that no other bus mode is enabled). port0 is also used to select the system startup configuration. during reset, port0 is configured to input, and each line is held high through an internal pullup device. each line can now be individually pulled to a low level (see dc-level specifications in the respective data sheets) through an external pulldown device. a default configuration is selected when the respective port0 lines are at a high level. through pulling individual lines to a low level, this default can be changed according to the needs of the applications. the internal pullup devices are designed such that an external pulldown resistors (see specification) can be used to apply a correct low level. these external pulldown resistors can remain connected to the port0 pins also during normal operation, however, care has to be taken such that they do not disturb the normal function of port0 (this might be the case, for example, if the external resistor is too strong). with the end of reset, the selected bus configuration will be written to the buscon0 register. the configuration of the high byte of port0, will be copied into the special register rp0h. this read-only register holds the selection for the number of chip selects and segment addresses. software can read this register in order to react according to the selected configuration, if required. note: when the reset is terminated, the internal pullup devices must be switched off by software and port0 will be switched to the appropriate operating mode. during external accesses in multiplexed bus modes port0 first outputs the 16-bit intra- segment address as an alternate output function. port0 is then switched to high- impedance input mode to read the incoming instruction or data. in 8-bit data bus mode, two memory cycles are required for word accesses, the first for the low byte and the second for the high byte of the word. during write cycles port0 outputs the data byte or word after outputting the address. during external accesses in demultiplexed bus modes port0 reads the incoming instruction or data word or outputs the data byte or word.
c165h parallel ports data sheet 133 2001-04-19 p r e l i m i n a r y - exc er pt - figure 28 port0 i/o and alternate functions when an external bus mode is enabled, the direction of the port pin and the loading of data into the port output latch are controlled by the bus controller hardware. the input of the port output latch is disconnected from the internal bus and is switched to the line labeled ?alternate data output? via a multiplexer. the alternate data can be the 16-bit intrasegment address or the 8/16-bit data information. the incoming data on port0 is read on the line ?alternate data input?. while an external bus mode is enabled, the user software should not write to the port output latch, otherwise unpredictable results may occur. when the external bus modes are disabled, the contents of the direction register last written by the user becomes active. figure 29 shows the structure of a port0 pin. p0h.7 p0h.6 p0h.5 p0h.4 p0h.3 p0h.2 p0h.1 p0h.0 p0l.7 p0l.6 p0l.5 p0l.4 p0l.3 p0l.2 p0l.1 p0l.0 port0 d7 d6 d5 d4 d3 d2 d1 d0 p0h p0l d15 d14 d13 d12 d11 d10 d9 d8 d7 d6 d5 d4 d3 d2 d1 d0 ad15 ad14 ad13 ad12 ad11 ad10 ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 ad1 ad0 ad15 ad14 ad13 ad12 ad11 ad10 ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 ad1 ad0 alternate function a) b) c) d) general purpose input/output 8-bit demux bus 16-bit demux bus 8-bit mux bus 16-bit mux bus
c165h parallel ports data sheet 134 2001-04-19 p r e l i m i n a r y - exc er p t - figure 29 block diagram of a port0 pin 7.2 port1 the two 8-bit ports p1h and p1l represent the higher and lower part of port1, respectively. both halfs of port1 can be written (eg. via a pec transfer) without effecting the other half. if this port is used for general purpose i/o, the direction of each line can be configured via the corresponding direction registers dp1h and dp1l. each port line can be switched into push/pull or open drain mode via the open drain control register odp1l and odp1h. for port pins configured as input (via dp1x or alternate function), an internal pull transistor is connected to the pad if register p1xpuden = ?1?, no matter wheter the c165h is in normal operation mode or in power down mode. either pulldown transistor or pullup transistor will be selected via p1xpudsel. mcb02231 output buffer mux 1 0 alternate data output latch port output 0 1 mux write p0h.y/p0l.y read p0h.y/p0l.y enable function alternate 0 1 mux read dp0h.y/dp0l.y write dp0h.y/dp0l.y direction input latch clock latch s u b l a n r e t n p0h.y p0l.y direction alternate y = 7...0
c165h parallel ports data sheet 135 2001-04-19 p r e l i m i n a r y - exc er pt - for port pins configured as output, the internal pull transistors are always disabled. the output driver is disabled in power down mode unless p1xphen = ?1?. after reset, p1xpuden and p1xpudsel are set to low signal. p1l (ff04 h / 82 h ) sfr reset value: - - 00 h p1h (ff06 h / 83 h ) sfr reset value: - - 00 h dp1l (f104 h / 82 h ) esfr reset value: - - 00 h dp1h (f106 h / 83 h ) esfr reset value: - - 00 h odp1l (fe24 h / 12 h ) sfr reset value: - - 00 h bit function p1x.y port data register p1h or p1l bit y 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p1l.0 p1l.1 p1l.2 p1l.3 p1l.4 p1l.5 p1l.6 p1l.7 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p1h.0 p1h.1 p1h.2 p1h.3 p1h.4 p1h.5 p1h.6 p1h.7 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - dp1l .7 dp1l .6 dp1l .5 dp1l .4 dp1l .3 dp1l .2 dp1l .1 dp1l .0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - dp1h .7 dp1h .6 dp1h .5 dp1h .4 dp1h .3 dp1h .2 dp1h .1 dp1h .0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - odp1 l.7 odp1 l.6 odp1 l.5 odp1 l.4 odp1 l.3 odp1 l.2 odp1 l.1 odp1 l.0
c165h parallel ports data sheet 136 2001-04-19 p r e l i m i n a r y - exc er p t - odp1h (fe26 h / 13 h ) sfr reset value: - - 00 h p1lpudsel (fe6c h / 36 h ) sfr reset value: - - 00 h p1hpudsel (fe6e h / 37 h ) sfr reset value: - - 00 h bit function dp1x.y port direction register dp1h or dp1l bit y dp1x.y = 0: port line p1x.y is an input (high-impedance) dp1x.y = 1: port line p1x.y is an output bit function odp1x.y port1x open drain control register bit y odp1x.y = 0: port line p1x.y output driver in push/pull mode odp1x.y = 1: port line p1x.y output driver in open drain mode bit function p1xpudsel.y pulldown/pullup selection p1xpudsel.y = 0: internal programmable pulldown transistor is selected p1xpudsel.y = 1: internal programmable pullup transistor is selected 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - odp1 h.7 odp1 h.6 odp1 h.5 odp1 h.4 odp1 h.3 odp1 h.2 odp1 h.1 odp1 h.0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p1l pud sel.7 p1l pud sel.6 p1l pud sel.5 p1l pud sel.4 p1l pud sel.3 p1l pud sel.2 p1l pud sel.1 p1l pud sel.0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p1h pud sel.7 p1h pud sel.6 p1h pud sel.5 p1h pud sel.4 p1h pud sel.3 p1h pud sel.2 p1h pud sel.1 p1h pud sel.0
c165h parallel ports data sheet 137 2001-04-19 p r e l i m i n a r y - exc er pt - p1lpuden (fe70 h / 38 h ) sfr reset value: - - 00 h p1hpuden (fe72 h / 39 h ) sfr reset value: - - 00 h p1lphen (fe74 h / 3a h ) sfr reset value: - - 00 h p1hphen (fe76 h / 3b h ) sfr reset value: - - 00 h bit function p1xpuden.y pulldown/pullup enable p1xpuden.y = 0: internal programmable pull transistor is disabled p1xpuden.y = 1: internal programmable pull transistor is enabled bit function p1xphen.y output driver enable in power down mode p1xphen.y = 0: output driver is disabled in power down mode p1xphen.y = 1: output driver is enabled in power down mode 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p1l pud en.7 p1l pud en.6 p1l pud en.5 p1l pud en.4 p1l pud en.3 p1l pud en.2 p1l pud en.1 p1l pud en.0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p1h pud en.7 p1h pud en.6 p1h pud en.5 p1h pud en.4 p1h pud en.3 p1h pud en.2 p1h pud en.1 p1h pud en.0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p1l phen .7 p1l phen .6 p1l phen .5 p1l phen .4 p1l phen .3 p1l phen .2 p1l phen .1 p1l phen .0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p1h phen .7 p1h phen .6 p1h phen .5 p1h phen .4 p1h phen .3 p1h phen .2 p1h phen .1 p1h phen .0
c165h parallel ports data sheet 138 2001-04-19 p r e l i m i n a r y - exc er p t - 7.2.1 alternate functions of port1 when a demultiplexed external bus is enabled, port1 is used as address bus. note that demultiplexed bus modes use port1 as a 16-bit port. otherwise all 16 port lines can be used for general purpose i/o. during external accesses in demultiplexed bus modes port1 outputs the 16-bit intra- segment address as an alternate output function. during external accesses in multiplexed bus modes, when no buscon register selects a demultiplexed bus mode, port1 is not used and is available for general purpose i/o. figure 30 port1 i/o and alternate functions when an external bus mode is enabled, the direction of the port pin and the loading of data into the port output latch are controlled by the bus controller hardware. the input of the port output latch is disconnected from the internal bus and is switched to the line labeled ?alternate data output? via a multiplexer. the alternate data is the 16-bit intrasegment address. while an external bus mode is enabled, the user software should not write to the port output latch, otherwise unpredictable results may occur. when the external bus modes are disabled, the contents of the direction register last written by the user becomes active. p1h.7 p1h.6 p1h.5 p1h.4 p1h.3 p1h.2 p1h.1 p1h.0 p1l.7 p1l.6 p1l.5 p1l.4 p1l.3 p1l.2 p1l.1 p1l.0 port1 p1h p1l a15 a14 a13 a12 a11 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 alternate function a) general purpose input/output 8/16-bit demux bus
c165h parallel ports data sheet 139 2001-04-19 p r e l i m i n a r y - exc er pt - figure 31 shows the structure of a port1 pin. figure 31 block diagram of a port1 pin 7.3 port2 in the c165h port 2 is an 8 -bit port. if port 2 is used for general purpose i/o, the direction of each line can be configured via the corresponding direction register dp2. each port line can be switched into push/pull or open drain mode via the open drain control register odp2. for port pins configured as input (via dp2 or alternate function), an internal pull transistor is connected to the pad if register p2puden = ?1?, no matter wheter the c165h is in normal operation mode or in power down mode. either pulldown transistor or pullup transistor will be selected via p2pudsel. for port pins configured as output, the internal pull transistors are always disabled. the output driver is disabled in power down mode unless p2phen = ?1?. mcb02232 output buffer mux 1 0 alternate data output latch port output 0 1 mux write p1h.y/p1l.y read p1h.y/p1l.y enable function alternate 0 1 mux read dp1h.y/dp1l.y write dp1h.y/dp1l.y direction input latch clock latch s u b l a n r e t n p1h.y p1l.y ? 1 ? y = 7...0
c165h parallel ports data sheet 140 2001-04-19 p r e l i m i n a r y - exc er p t - after reset, p2puden and p2pudsel are set to low signal. p2 (ffc0 h / e0 h ) sfr reset value: - - 00 h dp2 (ffc2 h / e1 h ) sfr reset value: - - 00 h odp2 (f1c2 h / e1 h ) esfr reset value: - - 00 h bit function p2.y port data register p2 bit y bit function dp2.y port direction register dp2 bit y dp2.y = 0: port line p2.y is an input (high-impedance) dp2.y = 1: port line p2.y is an output bit function odp2.y port 2 open drain control register bit y odp2.y = 0: port line p2.y output driver in push/pull mode odp2.y = 1: port line p2.y output driver in open drain mode p2.0 p2.1 p2.2 p2.4 p2.5 p2.6 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p2.7 p2.3 dp2.0 dp2.1 dp2.2 dp2.4 dp2.5 dp2.6 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - dp2.7 dp2.3 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - odp2 .7 odp2 .6 odp2 .5 odp2 .4 odp2 .3 odp2 .2 odp2 .1 odp2 .0
c165h parallel ports data sheet 141 2001-04-19 p r e l i m i n a r y - exc er pt - p2pudsel (fe78 h / 3c h ) sfr reset value: - - 00 h p2puden (fe7a h / 3d h ) sfr reset value: - - 00 h p2phen (fe7c h / 3e h ) sfr reset value: - - 00 h bit function p2pudsel.y pulldown/pullup selection p2pudsel.y = 0: internal programmable pulldown transistor is selected p2pudsel.y = 1: internal programmable pullup transistor is selected bit function p2puden.y pulldown/pullup enable p2puden.y = 0: internal programmable pull transistor is disabled p2puden.y = 1: internal programmable pull transistor is enabled bit function p2phen.y output driver enable in power down mode p2phen.y = 0: output driver is disabled in power down mode p2phen.y = 1: output driver is enabled in power down mode 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p2 pud sel.7 p2 pud sel.6 p2 pud sel.5 p2 pud sel.4 p2 pud sel.3 p2 pud sel.2 p2 pud sel.1 p2 pud sel.0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p2 pud en.7 p2 pud en.6 p2 pud en.5 p2 pud en.4 p2 pud en.3 p2 pud en.2 p2 pud en.1 p2 pud en.0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p2 phen .7 p2 phen .6 p2 phen .5 p2 phen .4 p2 phen .3 p2 phen .2 p2 phen .1 p2 phen .0
c165h parallel ports data sheet 142 2001-04-19 p r e l i m i n a r y - exc er p t - 7.3.1 alternate functions of port2 all port 2 lines (p2.7..p2.0) can serve as fast external interrupt inputs (ex7in...ex0in). table 20 summarizes the alternate functions of port 2. table 20 port 2 alternate functions: fast external interrupts figure 32 port 2 i/o and alternate functions the pins of port 2 combine internal bus data and alternate data output before the port latch input. note: as opposed to the c165h, in other existing infineon c16x devices ex0in is assigned to p2.8, ex1in is assigned to p2.9 ... and ex7in is assigned to p2.15 using the higher byte of port 2 instead of using the lower byte of port 2. port 2 pin alternate function p2.0 p2.1 p2.2 p2.3 p2.4 p2.5 p2.6 p2.7 ex0in fast external interrupt 0 input ex1in fast external interrupt 1 input ex2in fast external interrupt 2 input ex3in fast external interrupt 3 input ex4in fast external interrupt 4 input ex5in fast external interrupt 5 input ex6in fast external interrupt 6 input ex7in fast external interrupt 7 input - - - - - - - - p2.7 p2.6 p2.5 p2.4 p2.3 p2.2 p2.1 p2.0 port 2 - - - - - - - - ex7in ex6in ex5in ex4in ex3in ex2in ex1in ex0in alternate function a) general purpose input/output fast external interrupt input
c165h parallel ports data sheet 143 2001-04-19 p r e l i m i n a r y - exc er pt - figure 33 block diagram of a port 2 pin ( y = 7...0) mcb02230 output buffer alternate data input latch port output 0 1 mux write p2.y read p2.y read dp2.y write dp2.y direction write odp2.y read odp2.y open drain latch input latch clock latch s u b l a n r e t n p2.y xzin
c165h parallel ports data sheet 144 2001-04-19 p r e l i m i n a r y - exc er p t - 7.4 port3 if this 11-bit port is used for general purpose i/o, the direction of each line can be configured via the corresponding direction register dp3. each port lines can be switched into push/pull or open drain mode via the open drain control register odp3. note: due to pin limitations register bit p3.0..p3.2, p3.4 and p3.14 is not connected to an output pin. the port 3 bit-assignment is not consecutive to for compatibility with other c16x devices. for port pins configured as input (via dp3 or alternate function), an internal pull transistor is connected to the pad if register p3puden = ?1?, no matter wheter the c165h is in normal operation mode or in power down mode. either pulldown transistor or pullup transistor will be selected via p3pudsel. for port pins configured as output, the internal pull transistors are always disabled. the output driver is disabled in power down mode unless p3phen = ?1?. after reset, p3puden and p3pudsel are set to low signal. p3 (ffc4 h / e2 h ) sfrreset value: 0000 h bit function p3.y port data register p3 bit y 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw - rw - - - rw rw rw rw rw rw rw - rw rw - - - p3.3 - p3.5 p3.6 p3.7 p3.8 p3.9 p3.10 p3.11 p3.12 p3.13 - p3.15
c165h parallel ports data sheet 145 2001-04-19 p r e l i m i n a r y - exc er pt - dp3 (ffc6 h / e3 h ) sfr reset value: 0000 h odp3 (f1c6 h / e3 h ) esfr reset value: 0000 h p3pudsel (fe7e h / 3f h ) sfr reset value: - - 00 h bit function dp3.y port direction register dp3 bit y dp3.y = 0: port line p3.y is an input (high-impedance) dp3.y = 1: port line p3.y is an output bit function odp3.y port 3 open drain control register bit y odp3.y = 0: port line p3.y output driver in push/pull mode odp3.y = 1: port line p3.y output driver in open drain mode bit function p3pudsel.y pulldown/pullup selection p3pudsel.y = 0: internal programmable pulldown transistor is selected p3pudsel.y = 1: internal programmable pullup transistor is selected -- - 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw - rw - - - rw rw rw rw rw rw rw - rw rw dp3 .13 dp3 .11 dp3 .10 dp3 .9 dp3 .8 dp3 .7 dp3 .6 dp3 .5 - dp3 .3 - - - - dp3 .12 dp3 .15 -- - 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw - rw - - - rw rw rw rw rw rw rw - rw rw odp3 .13 odp3 .11 odp3 .10 odp3 .9 odp3 .8 odp3 .7 odp3 .6 odp3 .5 - odp3 .3 - - - - odp3 .15 odp3 .12 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 p3pu dsel. 15 p3pu dsel. 13 p3pu dsel. 5 p3pu dsel. 6 p3pu dsel. 7 p3pu dsel. 8 p3pu dsel. 3 p3pu dsel. 9 p3pu dsel. 10 p3pu dsel. 11 ----- rw - rw - - - rw rw rw rw rw rw rw - rw rw p3pu dsel. 12
c165h parallel ports data sheet 146 2001-04-19 p r e l i m i n a r y - exc er p t - p3puden (fe80 h / 40 h ) sfr reset value: - - 00 h p3phen (fe82 h / 41 h ) sfr reset value: - - 00 h bit function p3puden.y pulldown/pullup enable p3puden.y = 0: internal programmable pull transistor is disabled p3puden.y = 1: internal programmable pull transistor is enabled bit function p3phen.y output driver enable in power down mode p3phen.y = 0: output driver is disabled in power down mode p3phen.y = 1: output driver is enabled in power down mode 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 p3pu den. 15 p3pu den. 13 p3pu den. 5 p3pu den. 6 p3pu den. 7 p3pu den. 8 p3pu den. 3 p3pu den. 9 p3pu den. 10 p3pu den. 11 ----- rw - rw - - - rw rw rw rw rw rw rw - rw rw p3pu den. 12 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 p3 phen .15 p3 phen .13 p3 phen .5 p3 phen .6 p3 phen .7 p3 phen .8 p3 phen .3 p3 phen .9 p3 phen .10 p3 phen .11 ----- rw - rw - - - rw rw rw rw rw rw rw - rw rw p3 phen .12
c165h parallel ports data sheet 147 2001-04-19 p r e l i m i n a r y - exc er pt - 7.4.1 alternate functions of port3 the pins of port 3 serve for various functions which include external timer control lines, the two serial interfaces and the control lines bhe and clkout. table 21 summarizes the alternate functions of port 3. table 21 alternate functions of port 3 figure 34 port 3 i/o and alternate functions port 3 pin alternate function p3.0 p3.1 p3.2 p3.3 p3.4 p3.5 p3.6 p3.7 p3.8 p3.9 p3.10 p3.11 p3.12 p3.13 p3.14 p3.15 --- no pin assigned --- no pin assigned --- no pin assigned t3out timer 3 toggle output --- no pin assigned! t4in timer 4 count input (t3eud input, t2eud input) t3in timer 3 count input t2in timer 2 count input mrst ssc master receive / slave transmit mtsr ssc master transmit / slave receive txd0 asc transmit data output rxd0 asc receive data input bhe /wrh byte high enable / write high output sclk ssc shift clock input/output --- no pin assigned clkout system clock output p3.15 p3.13 p3.12 p3.11 p3.10 p3.9 p3.8 p3.7 p3.6 p3.5 p3.3 port 3 no pin clkout sclk bhe rxd0tx d0 mtsr mrst t2in t3in t4in t3out wrh alternate function a) b) general purpose input/output no pin no pin no pin no pin
c165h parallel ports data sheet 148 2001-04-19 p r e l i m i n a r y - exc er p t - the port structure of the port 3 pins depends on their alternate function (see figures below). when the on-chip peripheral associated with a port 3 pin is configured to use the alternate input function, it reads the input latch, which represents the state of the pin, via the line labeled ?alternate data input?. port 3 pins with alternate input functions are: t2in, t3in and t4in/t3eud/t2eud. when the on-chip peripheral associated with a port 3 pin is configured to use the alternate output function, its ?alternate data output? line is anded with the port output latch line. when using these alternate functions, the user must set the direction of the port line to output (dp3.y=1) and must set the port output latch (p3.y=1). otherwise the pin is in its high-impedance state (when configured as input) or the pin is stuck at '0' (when the port output latch is cleared). when the alternate output functions are not used, the ?alternate data output? line is in its inactive state, which is a high level ('1'). port 3 pins with alternate output functions are: t6out, t3out, txd0 and clkout. when the on-chip peripheral associated with a port 3 pin is configured to use both the alternate input and output function, the descriptions above apply to the respective current operating mode. the direction must be set accordingly. port 3 pins with alternate input/output functions are: mtsr, mrst, rxd0 and sclk. note: enabling the clkout function automatically enables the p3.15 output driver. setting bit dp3.15=?1? is not required.
c165h parallel ports data sheet 149 2001-04-19 p r e l i m i n a r y - exc er pt - figure 35 block diagram of a port 3 pin with alternate input or alternate output function ( y = 13, 11...5, 3) pin p3.12 (bhe /wrh ) is one more pin with an alternate output function. however, its structure is slightly different (see figure below), because after reset the bhe or wrh function must be used depending on the system startup configuration. in these cases there is no possibility to program any port latches before. thus the appropriate alternate function is selected automatically. if bhe /wrh is not used in the system, this pin can be used for general purpose i/o by disabling the alternate function (bytdis = ?1? / wrcfg=?0?). mcb02229 output buffer alternate data latch port output 0 1 mux write p3.y read p3.y read dp3.y write dp3.y direction write odp3.y read odp3.y open drain latch input latch clock latch s u b l a n r e t n input & output data alternate p3.y y = 13, 11...5, 3
c165h parallel ports data sheet 150 2001-04-19 p r e l i m i n a r y - exc er p t - figure 36 block diagram of pins p3.15 (clkout) and p3.12 (bhe /wrh ) note: enabling the bhe or wrh function automatically enables the p3.12 output driver. setting bit dp3.12=?1? is not required. during bus hold pin p3.12 is switched back to its standard function and is then controlled by dp3.12 and p3.12. keep dp3.12 = ?0? in this case to ensure floating in hold mode. 7.5 port4 if this 7-bit port is used for general purpose i/o, the direction of each line can be configured via the corresponding direction register dp4. each port line can be switched into push/pull or open drain mode via the open drain control register odp4. for port pins configured as input (via dp4 or alternate function), an internal pull transistor is connected to the pad if register p4puden = ?1?, no matter wheter the c165h is in normal operation mode or in power down mode. either pulldown transistor or pullup transistor will be selected via p4pudsel. for port pins configured as output, the internal pull transistors are always disabled. the output driver is disabled in power down mode unless p4phen = ?1?. mcb02073 output buffer mux 1 0 alternate data output latch port output 0 1 mux write p3.x read p3.x enable function alternate 0 1 mux read dp3.x write dp3.x direction ? 1 ? input latch clock latch n t e r n a l b u s p3.12/bhe p3.15/clkout x = 15, 12
c165h parallel ports data sheet 151 2001-04-19 p r e l i m i n a r y - exc er pt - after reset, p4puden and p4pudsel are set to low signal. p4 (ffc8 h / e4 h ) sfr reset value: - - 00 h dp4 (ffca h / e5 h ) sfr reset value: - - 00 h odp4 (f1ca h / e5 h ) esfr reset value: - - 00 h bit function p4.y port data register p4 bit y bit function dp4.y port direction register dp4 bit y dp4.y = 0: port line p4.y is an input (high-impedance) dp4.y = 1: port line p4.y is an output bit function odp4.y port 4 open drain control register bit y odp4.y = 0: port line p4.y output driver in push/pull mode odp4.y = 1: port line p4.y output driver in open drain mode 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - - rw - - - - p4.0 p4.1 p4.2 p4.3 p4.4 p4.5 p4.6 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - - rw - - - - dp4.0 dp4.1 dp4.2 dp4.3 dp4.4 dp4.5 dp4.6 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - - rw - - - - odp2 .6 odp2 .5 odp2 .4 odp2 .3 odp2 .2 odp2 .1 odp2 .0
c165h parallel ports data sheet 152 2001-04-19 p r e l i m i n a r y - exc er p t - p4pudsel (fe84 h / 42 h ) sfr reset value: - - 00 h p4puden (fe86 h / 43 h ) sfr reset value: - - 00 h p4phen (fe88 h / 44 h ) sfr reset value: - - 00 h bit function p4pudsel.y pulldown/pullup selection p4pudsel.y = 0: internal programmable pulldown transistor is selected p4pudsel.y = 1: internal programmable pullup transistor is selected bit function p4puden.y pulldown/pullup enable p4puden.y = 0: internal programmable pull transistor is disabled p4puden.y = 1: internal programmable pull transistor is enabled bit function p4phen.y output driver enable in power down mode p4phen.y = 0: output driver is disabled in power down mode p4phen.y = 1: output driver is enabled in power down mode 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - - rw - - - - p4 pud sel.6 p4 pud sel.5 p4 pud sel.4 p4 pud sel.3 p4 pud sel.2 p4 pud sel.1 p4 pud sel.0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - - rw - - - - p4 pud en.6 p4 pud en.5 p4 pud en.4 p4 pud en.3 p4 pud en.2 p4 pud en.1 p4 pud en.0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - - rw - - - - p4 phen .6 p4 phen .5 p4 phen .4 p4 phen .3 p4 phen .2 p4 phen .1 p4 phen .0
c165h parallel ports data sheet 153 2001-04-19 p r e l i m i n a r y - exc er pt - 7.5.1 alternate functions of port4 during external bus cycles that use segmentation (ie. an address space above 64 kbyte) a number of port 4 pins may output the segment address lines. the number of pins that is used for segment address output determines the external address space which is directly accessible. the other pins of port 4 (if any) may be used for general purpose i/o. if segment address lines are selected, the alternate function of port 4 may be necessary to access eg. external memory directly after reset. for this reason port 4 will be switched to its alternate function automatically. the number of segment address lines is selected via port0 during reset. the selected value can be read from bitfield salsel in register rp0h (read only) eg. in order to check the configuration during run time. table 22 summarizes the alternate functions of port 4 depending on the number of selected segment address lines (coded via bitfield salsel). table 22 alternate functions of port 4 figure 37 port 4 i/o and alternate functions port 4 pin std. function salsel=01 64 kb altern. function salsel=11256 kb altern. function salsel=00 1 mb altern. function salsel=10 8 mb p4.0 p4.1 p4.2 p4.3 p4.4 p4.5 p4.6 gen. purpose i/o gen. purpose i/o gen. purpose i/o gen. purpose i/o gen. purpose i/o gen. purpose i/o gen. purpose i/o seg. address a16 seg. address a17 gen. purpose i/o gen. purpose i/o gen. purpose i/o gen. purpose i/o gen. purpose i/o seg. address a16 seg. address a17 seg. address a18 seg. address a19 gen. purpose i/o gen. purpose i/o gen. purpose i/o seg. address a16 seg. address a17 seg. address a18 seg. address a19 seg. address a20 seg. address a21 seg. address a22 - - - - - - - - - p4.6 p4.5 p4.4 p4.3 p4.2 p4.1 p4.0 port 4 - - - - - - - - - a22 a21 a20 a19 a18 a17 a16 alternate function general purpose input/output
c165h parallel ports data sheet 154 2001-04-19 p r e l i m i n a r y - exc er p t - figure 38 block diagram of a port 4 pin (y = 6...0) 7.6 port6 if this 8-bit port is used for general purpose i/o, the direction of each line can be configured via the corresponding direction register dp6. each port line can be switched into push/pull or open drain mode via the open drain control register odp6. for port pins configured as input (via dp6 or alternate function), an internal pull transistor is connected to the pad if register p6puden = ?1?, no matter wheter the c165h is in normal operation mode or in power down mode. either pulldown transistor or pullup transistor will be selected via p6pudsel. for port pins configured as output, the internal pull transistors are always disabled. the output driver is disabled in power down mode unless p6phen = ?1?. after reset, p6puden and p6pudsel are set to low signal. mcb02075 output buffer mux 1 0 alternate data output latch port output 0 1 mux write p4.y read p4.y enable function alternate 0 1 mux read dp4.y write dp4.y direction ? 1 ? input latch clock latch s u b l a n r e t n p4.y
c165h parallel ports data sheet 155 2001-04-19 p r e l i m i n a r y - exc er pt - p6 (ffcc h / e6 h ) sfr reset value: - - 00 h dp6 (ffce h / e7 h ) sfr reset value: - - 00 h bit function p6.y port data register p6 bit y bit function dp6.y port direction register dp6 bit y dp6.y = 0: port line p6.y is an input (high-impedance) dp6.y = 1: port line p6.y is an output 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p6.0 p6.1 p6.2 p6.3 p6.4 p6.5 p6.6 p6.7 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - dp6.0 dp6.1 dp6.2 dp6.3 dp6.4 dp6.5 dp6.6 dp6.7
c165h parallel ports data sheet 156 2001-04-19 p r e l i m i n a r y - exc er p t - odp6 (f1ce h / e7 h ) esfr reset value: - - 00 h p6pudsel (fe90 h / 48 h ) sfr reset value: - - 00 h p6puden (fe92 h / 49 h ) sfr reset value: - - 00 h bit function odp6.y port 6 open drain control register bit y odp6.y = 0: port line p6.y output driver in push/pull mode odp6.y = 1: port line p6.y output driver in open drain mode bit function p6pudsel.y pulldown/pullup selection p6pudsel.y = 0: internal programmable pulldown transistor is selected p6pudsel.y = 1: internal programmable pullup transistor is selected bit function p6puden.y pulldown/pullup enable p6puden.y = 0: internal programmable pull transistor is disabled p6puden.y = 1: internal programmable pull transistor is enabled 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - odp6 .7 odp6 .6 odp6 .5 odp6 .4 odp6 .3 odp6 .2 odp6 .1 odp6 .0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p6 pud sel.7 p6 pud sel.6 p6 pud sel.5 p6 pud sel.4 p6 pud sel.3 p6 pud sel.2 p6 pud sel.1 p6 pud sel.0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p6 pud en.7 p6 pud en.6 p6 pud en.5 p6 pud en.4 p6 pud en.3 p6 pud en.2 p6 pud en.1 p6 pud en.0
c165h parallel ports data sheet 157 2001-04-19 p r e l i m i n a r y - exc er pt - p6phen (fe94 h / 4a h ) sfr reset value: - - 00 h 7.6.1 alternate functions of port6 a programmable number of chip select signals (cs4...cs0) derived from the bus control registers (buscon4...buscon0) can be output on 5 pins of port 6. the other 3 pins may be used for bus arbitration to accomodate additional masters in a c165h system. the number of chip select signals is selected via port0 during reset. the selected value can be read from bitfield cssel in register rp0h (read only) eg. in order to check the configuration during run time. table 23 summarizes the alternate functions of port 6 depending on the number of selected chip select lines (coded via bitfield cssel). table 23 alternate functions of port 6 bit function p6phen.y output driver enable in power down mode p6phen.y = 0: output driver is disabled in power down mode p6phen.y = 1: output driver is enabled in power down mode port 6 pin altern. function cssel = 10 altern. function cssel = 01 altern. function cssel = 00 altern. function cssel = 11 p6.0 p6.1 p6.2 p6.3 p6.4 gen. purpose i/o gen. purpose i/o gen. purpose i/o gen. purpose i/o gen. purpose i/o chip select cs0 chip select cs1 gen. purpose i/o gen. purpose i/o gen. purpose i/o chip select cs0 chip select cs1 chip select cs2 gen. purpose i/o gen. purpose i/o chip select cs0 chip select cs1 chip select cs2 chip select cs3 chip select cs4 p6.5 p6.6 p6.7 hold external hold request input hlda hold acknowledge output breq bus request output 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p6 phen .7 p6 phen .6 p6 phen .5 p6 phen .4 p6 phen .3 p6 phen .2 p6 phen .1 p6 phen .0
c165h parallel ports data sheet 158 2001-04-19 p r e l i m i n a r y - exc er p t - figure 39 port 6 i/o and alternate functions the chip select lines of port 6 additionally have an internal weak pullup device. this device is switched on under the following conditions:  always during reset  if the port 6 line is used as a chip select output, and the c165h is in hold mode (invoked through hold ), and the respective pin driver is in push/pull mode (odp6.x = ?0?). this feature is implemented to drive the chip select lines high during reset in order to avoid multiple chip selection, and to allow another master to access the external memory via the same chip select lines (wired-and), while the c165h is in hold mode. with odp6.x = ?1? (open drain output selected), the internal pullup device will not be active during hold mode; external pullup devices must be used in this case. when entering hold mode the cs lines are actively driven high for one clock phase, then the output level is controlled by the pullup devices (if activated). after reset the cs function must be used, if selected so. in this case there is no possibility to program any port latches before. thus the alternate function (cs ) is selected automatically in this case. note: the open drain output option can only be selected via software earliest during the initialization routine; at least signal cs0 will be in push/pull output driver mode directly after reset. - - - - - - - - p6.7 p6.6 p6.5 p6.4 p6.3 p6.2 p6.1 p6.0 port 6 - - - - - - - - breq hlda hold cs4 cs3 cs2 cs1 cs0 alternate function a) general purpose input/output
c165h parallel ports data sheet 159 2001-04-19 p r e l i m i n a r y - exc er pt - figure 40 block diagram of port 6 pins with an alternate output function the bus arbitration signals hold , hlda and breq are selected with bit hlden in register psw. when the bus arbitration signals are enabled via hlden, also these pins are switched automatically to the appropriate direction. note that the pin drivers for hlda and breq are automatically enabled, while the pin driver for hold is automatically disabled. mcb01982 output buffer mux 1 0 alternate data output latch port output 0 1 mux write p6.y read p6.y enable function alternate 0 1 mux read dp6.y write dp6.y direction write odp6.y read odp6.y open drain latch ? 1 ? input latch clock latch n t e r n a l b u s p6.y
c165h parallel ports data sheet 160 2001-04-19 p r e l i m i n a r y - exc er p t - figure 41 block diagram of pin p6.5 (hold ) 7.7 port7 in the c165h port 7 is an 6-bit general purpose i/o port. the direction of each line can be configured via the corresponding direction register dp7. each port line can be switched into push/pull or open drain mode via the open drain control register odp7. note: there are no alternate functions for port 7. for port pins configured as input via dp7, an internal pull transistor is connected to the pad if register p7puden = ?1?, no matter wheter the c165h is in normal operation mode or in power down mode. either pulldown transistor or pullup transistor will be selected via p7pudsel. mcb01983 output buffer alternate data input latch port output 0 1 mux write p6.y read p6.y read dp6.y write dp6.y direction write odp6.y read odp6.y open drain latch input latch clock latch s u b l a n r e t n p6.5/hold
c165h parallel ports data sheet 161 2001-04-19 p r e l i m i n a r y - exc er pt - for port pins configured as output, the internal pull transistors are always disabled. the output driver is disabled in power down mode unless p7phen = ?1?. after reset, p7puden and p7pudsel are set to low signal. p7 (ffd0 h / e8 h ) sfr reset value: - - 00 h dp7 (ffd2 h / e9 h ) sfr reset value: - - 00 h odp7 (f1d2 h / e9 h ) esfr reset value: - - 00 bit function p7.y port data register p7 bit y bit function dp7.y port direction register dp7 bit y dp7.y = 0: port line p7.y is an input (high-impedance) dp7.y = 1: port line p7.y is an output bit function odp7.y port 7 open drain control register bit y odp7.y = 0: port line p7.y output driver in push/pull mode odp7.y = 1: port line p7.y output driver in open drain mode p7.0 p7.1 p7.2 p7.4 p7.5 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - - - - - - - p7.3 dp7.0 dp7.1 dp7.2 dp7.4 dp7.5 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - - - - - - - dp7.3 odp7 .0 odp7 .1 odp7 .2 odp7 .4 odp7 .5 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - - - - - - - odp7 .3
c165h parallel ports data sheet 162 2001-04-19 p r e l i m i n a r y - exc er p t - p7pudsel (fe96 h / 4b h ) sfr reset value: - - 00 h p7puden (fe98 h / 4c h ) sfr reset value: - - 00 h p7phen (fe9a h / 4d h ) sfr reset value: - - 00 h bit function p7pudsel.y pulldown/pullup selection p7pudsel.y = 0: internal programmable pulldown transistor is selected p7pudsel.y = 1: internal programmable pullup transistor is selected bit function p7puden.y pulldown/pullup enable p7puden.y = 0: internal programmable pull transistor is disabled p7puden.y = 1: internal programmable pull transistor is enabled bit function p7phen.y output driver enable in power down mode p7phen.y = 0: output driver is disabled in power down mode p7phen.y = 1: output driver is enabled in power down mode 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - - - - - - - p7 pud sel.5 p7 pud sel.4 p7 pud sel.3 p7 pud sel.2 p7 pud sel.1 p7 pud sel.0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - - - - - - - p7 pud en.5 p7 pud en.4 p7 pud en.3 p7 pud en.2 p7 pud en.1 p7 pud en.0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw - - - - rw rw - - - - p6 phen .5 p6 phen .4 p6 phen .3 p6 phen .2 p6 phen .1 p6 phen .0
c165h dedicated pins data sheet 163 2001-04-19 p r e l i m i n a r y - exc er pt - 8 dedicated pins most of the input/output or control signals of the functional the c165h are realized as alternate functions of pins of the parallel ports. there is, however, a number of signals that use separate pins, including the iom-2 interface, the oscillator, special control signals and the power supply. table 24 summarizes all dedicated pins of the c165h. table 24 dedicated pins the address latch enable signal ale controls external address latches that provide a stable address in multiplexed bus modes. ale is activated for every external bus cycle independent of the selected bus mode, ie. it is also activated for bus cycles with a demultiplexed address bus. when an external bus is enabled (one or more of the busact bits set) also x-peripheral accesses will generate an active ale signal. ale is not activated for internal accesses, ie. the internal ram and the special function registers. in single chip mode, ie. when no external bus is enabled (no busact bit set), ale will also remain inactive for x-peripheral accesses. external read strobe rd controls the output drivers of external memory or peripherals when the c165h reads data from these external devices. during reset and during hold mode an internal pullup ensures an inactive (high) level on the rd output. pin(s) function ale address latch enable rd external read strobe wr /wrl external write/write low strobe ready ready input ea external access enable nmi non-maskable interrupt input rstin reset input rstout reset output xtal1, xtal2 oscillator input/output clkmode oscillator clock input mode select du, dd, dcl, fsc iom-2 brkin , brkout ocds tdi, tdo, tck, tms, trst jtag interface test test mode enable vdd, gnd power supply and ground (19 pins vdd, 19 pins gnd)
c165h dedicated pins data sheet 164 2001-04-19 p r e l i m i n a r y - exc er p t - external write strobe wr /wrl controls the data transfer from the c165h to an external memory or peripheral device. this pin may either provide an general wr signal activated for both byte and word write accesses, or specifically control the low byte of an external 16-bit device (wrl ) together with the signal wrh (alternate function of p3.12/ bhe ). during reset and during hold mode an internal pullup ensures an inactive (high) level on the wr /wrl output. note: whether rd and wr /wrl remain idle during x-peripheral accesses depends on the value of bit visible of register syscon. ready input ready receives a control signal from an external memory or peripheral device that is used to terminate an external bus cycle, provided that this function is enabled for the current bus cycle. ready may be used as synchronous ready or may be evaluated asynchronously. when waitstates are defined for a ready controlled address window the ready input is not evaluated during these waitstates. external access enable pin ea is dedicated for on-chip rom derivates. in this case it determines, if the chip after reset starts fetching code from the internal rom area (ea =?1?) or via the external bus interface (ea =?0?). for the rom-less c165h be sure to hold this input low. non-maskable interrupt input nmi allows to trigger a high priority trap via an external signal (eg. a power-fail signal). it also serves to validate the pwrdn instruction that switches the c165h into power-down mode. the nmi pin is sampled with every cpu clock cycle to detect transitions. oscillator input xtal1 and output xtal2 connect the internal pierce oscillator to the external crystal. the oscillator provides an inverter and a feedback element. the standard external oscillator circuitry (see figure below) comprises the crystal, two low end capacitors and series resistor to limit the current through the crystal. the additional lc combination is only required for 3rd overtone crystals to suppress oscillation in the fundamental mode. a test resistor (r q ) may be temporarily inserted to measure the oscillation allowance of the oscillator circuitry. an external clock signal may be fed to the input xtal1, leaving xtal2 open. note: it is strongly recommended to measure the oscillation allowance (or margin) in the final target system (layout) to determine the optimum parameters for the oscillator operation. the following starting configuration is recommended to be used for the c165h: quarz: c l = 30 pf (max.), r s = 70 ohm (max.), accuracy: 96 ppm or better external: circuitry: c a = c b = 47 pf (max.), no serial resistor (rx2 = 0)
c165h dedicated pins data sheet 165 2001-04-19 p r e l i m i n a r y - exc er pt - note: please check the infineon application notes in addition to this recommendation. figure 42 external oscillator circuitry the clock mode select clkmode clkmode must be low if an external crystal is used. high signal enables the direct clock input path and switches the internal oscillator in power down mode.. the reset input rstin allows to put the c165h into the well defined reset condition either at power-up or external events like a hardware failure or manual reset. the input voltage threshold of the rstin pin is raised compared to the standard pins in order to minimize the noise sensitivity of the reset input. the reset output rstout provides a special reset signal for external circuitry. rstout is activated at the beginning of the reset sequence, triggered via rstin , a watchdog timer overflow or by the srst instruction. rstout remains active (low) until the einit instruction is executed. this allows to initialize the controller before the external circuitry is activated. the power supply pins vdd and gnd provide the power supply for the digital logic of the c165h. the respective vcc/vss pairs should be decoupled as close to the pins as possible. for best results it is recommended to implement two-level decoupling, eg. (the widely used) 100 nf in parallel with 30...40 pf capacitors which deliver the peak currents. note: all vdd pins and all gnd pins must be connected to the power supply and ground, respectively. xtal1 xtal2 rx2 r q c a c b
c165h external bus interface data sheet 166 2001-04-19 p r e l i m i n a r y - exc er p t - 9 external bus interface although the c165h provides a powerful set of on-chip peripherals and on-chip ram areas, these internal units only cover a small fraction of its address space of up to 8 mbyte. the external bus interface allows to access external peripherals and additional volatile and non-volatile memory. the external bus interface provides a number of configurations, so it can be taylored to fit perfectly into a given application system. figure 43 sfrs and port pins associated with the external bus interface accesses to external memory or peripherals are executed by the integrated external bus controller (ebc). the function of the ebc is controlled via the syscon register and the busconx and addrselx registers. the busconx registers specify the external bus cycles in terms of address (mux/demux), data (16-bit/8-bit), chip selects and length (waitstates / ready control / ale / rw delay). these parameters are used for accesses within a specific address area which is defined via the corresponding register addrselx. the four pairs buscon1/addrsel1...buscon4/addrsel4 allow to define four independent ?address windows?, while all external accesses outside these windows are controlled via register buscon0. p4 buscon0 buscon1 buscon2 addrsel4 p0l / p0h p6 addrsel1 odp6 p0l/p0h port0 data registers p1l/p1h port1 data registers dp3 port 3 direction control register p3 port 3 data register p4 port 4 data register odp6 port 6 open drain control register dp6 port 6 direction control register p6 port 6 data register port0 ea port1 rstin ale ready rd wr /wrl bhe /wrh syscon control registers addrselx address range select register 1...4 busconx bus mode control register 0...4 syscon system control register rp0h port p0h reset configuration register ports & direction control alternate functions address registers mode registers control registers buscon3 p1l / p1h buscon4 addrsel2 rp0h dp6 dp3 p3 addrsel3
c165h external bus interface data sheet 167 2001-04-19 p r e l i m i n a r y - exc er pt - single chip mode single chip mode is entered, when pin ea is high during reset. in this case register buscon0 is initialized with 0000 h , which also resets bit busact0, so no external bus is enabled. in single chip mode the c165h operates only with and out of internal resources. no external bus is configured and no external peripherals and/or memory can be accessed. also no port lines are occupied for the bus interface. when running in single chip mode, however, external access may be enabled by configuring an external bus under software control. note: any attempt to access a location in the external memory space in single chip mode results in the hardware trap illbus. 9.1 external bus modes when the external bus interface is enabled (bit busactx=?1?) and configured (bitfield btyp), the c165h uses a subset of its port lines together with some control lines to build the external bus. the bus configuration (btyp) for the address windows (buscon4...buscon1) is selected via software typically during the initialization of the system. the bus configuration (btyp) for the default address range (buscon0) is selected via port0 during reset, provided that pin ea is low during reset. otherwise buscon0 may be programmed via software just like the other buscon registers. the 16 mbyte address space of the c165h is divided into 256 segments of 64 kbyte each. the 16-bit intra-segment address is output on port0 for multiplexed bus modes or on port1 for demultiplexed bus modes. when segmentation is disabled, only one 64 kbyte segment can be used and accessed. otherwise additional address lines may be output on port 4, and/or several chip select lines may be used to select different memory banks or peripherals. these functions are selected during reset via bitfields salsel and cssel of register rp0h, respectively. note: bit sgtdis of register syscon defines, if the csp register is saved during interrupt entry (segmentation active) or not (segmentation disabled). btyp encoding external data bus width external address bus mode 0 0 8-bit data demultiplexed addresses 0 1 8-bit data multiplexed addresses 1 0 16-bit data demultiplexed addresses 1 1 16-bit data multiplexed addresses
c165h external bus interface data sheet 168 2001-04-19 p r e l i m i n a r y - exc er p t - multiplexed bus modes in the multiplexed bus modes the 16-bit intra-segment address as well as the data use port0. the address is time-multiplexed with the data and has to be latched externally. the width of the required latch depends on the selected data bus width, ie. an 8-bit data bus requires a byte latch (the address bits a15...a8 on p0h do not change, while p0l multiplexes address and data), a 16-bit data bus requires a word latch (the least significant address line a0 is not relevant for word accesses). the upper address lines (an...a16) are permanently output on port 4 (if segmentation is enabled) and do not require latches. the ebc initiates an external access by generating the address latch enable signal (ale) and then placing an address on the bus. the falling edge of ale triggers an external latch to capture the address. after a period of time during which the address must have been latched externally, the address is removed from the bus. the ebc now activates the respective command signal (rd , wr , wrl , wrh ). data is driven onto the bus either by the ebc (for write cycles) or by the external memory/peripheral (for read cycles). after a period of time, which is determined by the access time of the memory/ peripheral, data become valid. read cycles: input data is latched and the command signal is now deactivated. this causes the accessed device to remove its data from the bus which is then tri-stated again. write cycles: the command signal is now deactivated. the data remain valid on the bus until the next external bus cycle is started.
c165h external bus interface data sheet 169 2001-04-19 p r e l i m i n a r y - exc er pt - figure 44 multiplexed bus cycle demultiplexed bus modes in the demultiplexed bus modes the 16-bit intra-segment address is permanently output on port1, while the data uses port0 (16-bit data) or p0l (8-bit data). the upper address lines are permanently output on port 4 (if selected via salsel during reset). no address latches are required. the ebc initiates an external access by placing an address on the address bus. after a programmable period of time the ebc activates the respective command signal (rd , wr , wrl , wrh ). data is driven onto the data bus either by the ebc (for write cycles) or by the external memory/peripheral (for read cycles). after a period of time, which is determined by the access time of the memory/peripheral, data become valid. read cycles: input data is latched and the command signal is now deactivated. this causes the accessed device to remove its data from the data bus which is then tri-stated again. write cycles: the command signal is now deactivated. if a subsequent external bus cycle is required, the ebc places the respective address on the address bus. the data remain valid on the bus until the next external bus cycle is started. mct02060 address segment (p4) ale bus (p0) data/instr. address rd address data bus (p0) wr bus cycle
c165h external bus interface data sheet 170 2001-04-19 p r e l i m i n a r y - exc er p t - figure 45 demultiplexed bus cycle switching between the bus modes the ebc allows to switch between different bus modes dynamically, ie. subsequent external bus cycles may be executed in different ways. certain address areas may use multiplexed or demultiplexed buses or use ready control or predefined waitstates. a change of the external bus characteristics can be initiated in two different ways: reprogramming the buscon and/or addrsel registers allows to either change the bus mode for a given address window, or change the size of an address window that uses a certain bus mode. reprogramming allows to use a great number of different address windows (more than buscons are available) on the expense of the overhead for changing the registers and keeping appropriate tables. switching between predefined address windows automatically selects the bus mode that is associated with the respective window. predefined address windows allow to use different bus modes without any overhead, but restrict their number to the number of buscons. however, as buscon0 controls all address areas, which are not covered by the other buscons, this allows to have gaps between these windows, which use the bus mode of buscon0. port1 will output the intra-segment address, when any of the buscon registers selects a demultiplexed bus mode, even if the current bus cycle uses a multiplexed bus mode. this allows to have an external address decoder connected to port1 only, while using it for all kinds of bus cycles. mcd02061 address address (p1) ale bus (p0) rd data bus (p0) wr segment (p4) bus cycle data/instr.
c165h external bus interface data sheet 171 2001-04-19 p r e l i m i n a r y - exc er pt - note: never change the configuration for an address area that currently supplies the instruction stream. due to the internal pipelining it is very difficult to determine the first instruction fetch that will use the new configuration. only change the configuration for address areas that are not currently accessed. this applies to buscon registers as well as to addrsel registers. the usage of the buscon/addrsel registers is controlled via the issued addresses. when an access (code fetch or data) is initiated, the respective generated physical address defines, if the access is made internally, uses one of the address windows defined by addrsel4...1, or uses the default configuration in buscon0. after initializing the active registers, they are selected and evaluated automatically by interpreting the physical address. no additional switching or selecting is necessary during run time, except when more than the four address windows plus the default is to be used. switching from demultiplexed to multiplexed bus mode represents a special case. the bus cycle is started by activating ale and driving the address to port 4 and port1 as usual, if another buscon register selects a demultiplexed bus. however, in the multiplexed bus modes the address is also required on port0. in this special case the address on port0 is delayed by one cpu clock cycle, which delays the complete (multiplexed) bus cycle and extends the corresponding ale signal (see figure below). this extra time is required to allow the previously selected device (via demultiplexed bus) to release the data bus, which would be available in a demultiplexed bus cycle.
c165h external bus interface data sheet 172 2001-04-19 p r e l i m i n a r y - exc er p t - figure 46 switching from demultiplexed to multiplexed bus mode external data bus width the ebc can operate on 8-bit or 16-bit wide external memory/peripherals. a 16-bit data bus uses port0, while an 8-bit data bus only uses p0l, the lower byte of port0. this saves on address latches, bus transceivers, bus routing and memory cost on the expense of transfer time. the ebc can control word accesses on an 8-bit data bus as well as byte accesses on a 16-bit data bus. word accesses on an 8-bit data bus are automatically split into two subsequent byte accesses, where the low byte is accessed first, then the high byte. the assembly of bytes to words and the disassembly of words into bytes is handled by the ebc and is transparent to the cpu and the programmer. byte accesses on a 16-bit data bus require that the upper and lower half of the memory can be accessed individually. in this case the upper byte is selected with the bhe signal, while the lower byte is selected with the a0 signal. so the two bytes of the memory can be enabled independent from each other, or together when accessing words. when writing bytes to an external 16-bit device, which has a single cs input, but two wr enable inputs (for the two bytes), the ebc can directly generate these two write control signals. this saves the external combination of the wr signal with a0 or bhe . in this case pin wr serves as wrl (write low byte) and pin bhe serves as wrh (write high mcd02234 address data/instr. address address data bus cycle address address (p1) ale rd data wr segment (p4) bus cycle bus (p0) bus (p0) demultiplexed multiplexed idle state data/instr.
c165h external bus interface data sheet 173 2001-04-19 p r e l i m i n a r y - exc er pt - byte). bit wrcfg in register syscon selects the operating mode for pins wr and bhe . the respective byte will be written on both data bus halfs. when reading bytes from an external 16-bit device, whole words may be read and the c165h automatically selects the byte to be input and discards the other. however, care must be taken when reading devices that change state when being read, like fifos, interrupt status registers, etc. in this case individual bytes should be selected using bhe and a0. note: port1 gets available for general purpose i/o, when none of the buscon registers selects a demultiplexed bus mode. disable/enable control for pin bhe ( bytdis) bit bytdis is provided for controlling the active low byte high enable (bhe ) pin. the function of the bhe pin is enabled, if the bytdis bit contains a '0'. otherwise, it is disabled and the pin can be used as standard i/o pin. the bhe pin is implicitly used by the external bus controller to select one of two byte-organized memory chips, which are connected to the c165h via a word-wide external data bus. after reset the bhe function is automatically enabled (bytdis = '0'), if a 16-bit data bus is selected during reset, otherwise it is disabled (bytdis=?1?). it may be disabled, if byte access to 16-bit memory is not required, and the bhe signal is not used. segment address generation during external accesses the ebc generates a (programmable) number of address lines on port 4, which extend the 16-bit address output on port0 or port1, and so increase the accessible address space. the number of segment address lines is selected during reset and coded in bit field salsel in register rp0h (see table below). bus mode transfer rate ( speed factor for byte/word/dword access ) system requirements free i/o lines 8-bit multiplexed very low ( 1.5 / 3 / 6 ) low (8-bit latch, byte bus) p1h, p1l 8-bit demultipl. low ( 1 / 2 / 4 ) very low (no latch, byte bus) p0h 16-bit multiplexed high ( 1.5 / 1.5 / 3 ) high (16-bit latch, word bus) p1h, p1l 16-bit demultipl. very high ( 1 / 1 / 2 ) low (no latch, word bus) --- salsel segment address lines directly accessible address space 1 1 two: a17...a16 256 kbyte (default without pull-downs) 1 0 seven: a22...a16 8 mbyte (maximum) 0 1 none 64 kbyte (minimum) 0 0 four: a19...a16 1 mbyte
c165h external bus interface data sheet 174 2001-04-19 p r e l i m i n a r y - exc er p t - note: the total accessible address space may be increased by accessing several banks which are distinguished by individual chip select signals. cs signal generation during external accesses the ebc can generate a (programmable) number of cs lines on port 6, which allow to directly select external peripherals or memory banks without requiring an external decoder. the number of cs lines is selected during reset and coded in bit field cssel in register rp0h (see table below). the csx outputs are associated with the busconx registers and are driven active (low) for any access within the address area defined for the respective buscon register. for any access outside this defined address area the respective csx signal will go inactive (high). at the beginning of each external bus cycle the corresponding valid cs signal is determined and activated. all other cs lines are deactivated (driven high) at the same time. note: the csx signals will not be updated for an access to any internal address area (ie. when no external bus cycle is started), even if this area is covered by the respective addrselx register. an access to an on-chip x-peripheral deactivates all external cs signals. upon accesses to address windows without a selected cs line all selected cs lines are deactivated. the chip select signals allow to be operated in four different modes, which are selected via bits cswenx and csrenx in the respective busconx register. address chip select signals remain active until an access to another address window. an address chip select becomes active with the falling edge of ale and becomes inactive with the falling edge of ale of an external bus cycle that accesses a different address area. no spikes will be generated on the chip select lines. cssel chip select lines note 1 1 five: cs 4 ...cs0 default without pull-downs 1 0 none port 6 pins free for i/o 0 1 two: cs1 ...cs0 0 0 three: cs2 ...cs0 cswenx csrenx chip select mode 0 0 address chip select (default after reset, mode for cs0 ) 0 1 read chip select 1 0 write chip select 1 1 read/write chip select
c165h external bus interface data sheet 175 2001-04-19 p r e l i m i n a r y - exc er pt - read or write chip select signals remain active only as long as the associated control signal (rd or wr ) is active. this also includes the programmable read/write delay. read chip select is only activated for read cycles, write chip select is only activated for write cycles, read/write chip select is activated for both read and write cycles (write cycles are assumed, if any of the signals wrh or wrl gets active). these modes save external glue logic, when accessing external devices like latches or drivers that only provide a single enable input. note: cs0 provides an address chip select directly after reset (except for single chip mode) when the first instruction is fetched. internal pullup devices hold all cs lines high during reset. after the end of a reset sequence the pullup devices are switched off and the pin drivers control the pin levels on the selected cs lines. not selected cs lines will enter the high-impedance state and are available for general purpose i/o. the pullup devices are also active during bus hold on the selected cs lines, while hlda is active and the respective pin is switched to push/pull mode. open drain outputs will float during bus hold. in this case external pullup devices are required or the new bus master is responsible for driving appropriate levels on the cs lines. segment address versus chip select the external bus interface of the c165h supports many configurations for the external memory. by increasing the number of segment address lines the c165h can address a linear address space of 256 kbyte, 1 mbyte or 8 mbyte. this allows to implement a large sequential memory area, and also allows to access a great number of external devices, using an external decoder. by increasing the number of cs lines the c165h can access memory banks or peripherals without external glue logic. these two features may be combined to optimize the overall system performance. enabling 4 segment address lines and 5 chip select lines eg. allows to access five memory banks of 8 mbyte each. so the available address space is 40 mbyte (without glue logic). note: bit sgtdis of register syscon defines, if the csp register is saved during interrupt entry (segmentation active) or not (segmentation disabled). 9.2 programmable bus characteristics important timing characteristics of the external bus interface have been made user programmable to allow to adapt it to a wide range of different external bus and memory configurations with different types of memories and/or peripherals. the following parameters of an external bus cycle are programmable:  ale control defines the ale signal length and the address hold time after its falling edge  memory cycle time (extendable with 1...15 waitstates) defines the allowable access time  memory tri-state time (extendable with 1 waitstate) defines the time for a data driver to float
c165h external bus interface data sheet 176 2001-04-19 p r e l i m i n a r y - exc er p t -  read/write delay time defines when a command is activated after the falling edge of ale  ready control defines, if a bus cycle is terminated internally or externally note: internal accesses are executed with maximum speed and therefore are not programmable. external acceses use the slowest possible bus cycle after reset. the bus cycle timing may then be optimized by the initialization software. figure 47 programmable external bus cycle ale length control the length of the ale signal and the address hold time after its falling edge are controlled by the alectlx bits in the buscon registers. when bit alectl is set to ?1?, external bus cycles accessing the respective address window will have their ale signal prolonged by half a cpu clock. also the address hold time after the falling edge of ale (on a multiplexed bus) will be prolonged by half a cpu clock, so the data transfer within rd/wr data addr ale alectl data rd/wr addr ale mttc mctc mcd02225
c165h external bus interface data sheet 177 2001-04-19 p r e l i m i n a r y - exc er pt - a bus cycle refers to the same clkout edges as usual (ie. the data transfer is delayed by one cpu clock). this allows more time for the address to be latched. note: alectl0 is ?1? after reset to select the slowest possible bus cycle, the other alectlx are ?0? after reset. figure 48 ale length control programmable memory cycle time the c165h allows the user to adjust the controller's external bus cycles to the access time of the respective memory or peripheral. this access time is the total time required to move the data to the destination. it represents the period of time during which the controller?s signals do not change. setup (p0) wr bus address data (p0) bus rd (p4) ale segment normal multiplexed bus cycle address address data/instr. address data mcd02235 lengthened multiplexed bus cycle address address hold data/instr.
c165h external bus interface data sheet 178 2001-04-19 p r e l i m i n a r y - exc er p t - figure 49 memory cycle time the external bus cycles of the c165h can be extended for a memory or peripheral, which cannot keep pace with the controller?s maximum speed, by introducing wait states during the access (see figure above). during these memory cycle time wait states, the cpu is idle, if this access is required for the execution of the current instruction. the memory cycle time wait states can be programmed in increments of one cpu clock within a range from 0 to 15 (default after reset) via the mctc fields of the buscon registers. 15- waitstates will be inserted. programmable memory tri-state time the c165h allows the user to adjust the time between two subsequent external accesses to account for the tri-state time of the external device. the tri-state time defines, when the external device has released the bus after deactivation of the read command (rd ). mct02063 address segment ale bus (p0) address rd address data bus (p0) wr mctc wait states (1...15) bus cycle data/instr.
c165h external bus interface data sheet 179 2001-04-19 p r e l i m i n a r y - exc er pt - figure 50 memory tri-state time the output of the next address on the external bus can be delayed for a memory or peripheral, which needs more time to switch off its bus drivers, by introducing a wait state after the previous bus cycle (see figure above). during this memory tri-state time wait state, the cpu is not idle, so cpu operations will only be slowed down if a subsequent external instruction or data fetch operation is required during the next instruction cycle. the memory tri-state time waitstate requires one cpu clock (28 ns at f cpu = 36 mhz) and is controlled via the mttcx bits of the buscon registers. a waitstate will be inserted, if bit mttcx is ?0? (default after reset). note: external bus cycles in multiplexed bus modes implicitly add one tri-state time waitstate in addition to the programmable mttc waitstate. read/write signal delay the c165h allows the user to adjust the timing of the read and write commands to account for timing requirements of external peripherals. the read/write delay controls the time between the falling edge of ale and the falling edge of the command. without read/ write delay the falling edges of ale and command(s) are coincident (except for propagation delays). with the delay enabled, the command(s) become active half a cpu clock after the falling edge of ale. the read/write delay does not extend the memory cycle time, and does not slow down the controller in general. in multiplexed bus modes, however, the data drivers of an external device may conflict with the c165h?s address, when the early rd signal is used. therefore multiplexed bus cycles should always be programmed with read/write delay. mct02065 segment ale bus (p0) address rd mttc wait state address bus cycle data/instr.
c165h external bus interface data sheet 180 2001-04-19 p r e l i m i n a r y - exc er p t - figure 51 read/write delay the read/write delay is controlled via the rwdcx bits in the buscon registers. the command(s) will be delayed, if bit rwdcx is ?0? (default after reset). early wr signal deactivation the duration of an external write access can be shortened by one tcl. the wr signal is activated (driven low) in the standard way, but can be deactivated (driven high) one tcl earlier than defined in the standard timing. in this case, also the data output drivers will be deactivated one tcl earlier. this is especially useful in systems which operate on higher cpu clock frequencies and employ external modules (memories, peripherals, etc.) which switch on their own data drivers very fast in response to e.g. a chip select signal. conflicts between the c165h and the external peripheral?s output drivers can be avoided then by selecting early wr for the c165h. note: make sure that the reduced wr low time then still matches the requirements of the external peripheral/memory. mct02066 address segment ale bus (p0) 1) rd address data bus (p0) wr read/write delay bus cycle data/instr. the data drivers from the previous bus cycle should be disabled when the rd signal becomes active. 1)
c165h external bus interface data sheet 181 2001-04-19 p r e l i m i n a r y - exc er pt - early wr deactivation is controlled via the ewenx bits in the buscon registers (see page 184). the wr signal will be shortened if bit ewenx is set to ?1? signal. default after reset is a standard wr signal (ewenx = ?0?). 9.3 ready controlled bus cycles for situations, where the programmable waitstates are not enough, or where the response (access) time of a peripheral is not constant, the c165h provides external bus cycles that are terminated via a ready input signal (synchronous or asynchronous). in this case the c165h first inserts a programmable number of waitstates (0...7) and then monitors the ready line to determine the actual end of the current bus cycle. the external device drives ready low in order to indicate that data have been latched (write cycle) or are available (read cycle). figure 52 ready controlled bus cycles the ready function is enabled via the rdyenx bits in the buscon registers. when this function is selected (rdyenx = ?1?), only the lower 3 bits of the respective mctc bit field define the number of inserted waitstates (0...7), while the msb of bit field mctc selects the ready operation: mctc.3 = ? 0 ? : synchronous ready , ie. the ready signal must meet setup and hold times. mctc.3 = ? 1 ? : asynchronous ready , ie. the ready signal is synchronized internally. evaluation (sampling) of the ready input aready sready : rd/wr ale 2. ws with active ready 1. ws bus cycle mcd02237 extended via ready 1. ws 2. ws bus cycle
c165h external bus interface data sheet 182 2001-04-19 p r e l i m i n a r y - exc er p t - synchronous ready provides the fastest bus cycles, but requires setup and hold times to be met. the clkout signal should be enabled and may be used by the peripheral logic to control the ready timing in this case. asynchronous ready is less restrictive, but requires additional waitstates caused by the internal synchronization. as the asynchronous ready is sampled earlier (see figure above) programmed waitstates may be necessary to provide proper bus cycles (see also notes on ?normally-ready? peripherals below). a ready signal (especially asynchronous ready ) that has been activated by an external device may be deactivated in response to the trailing (rising) edge of the respective command (rd or wr ). note: when the ready function is enabled for a specific address window, each bus cycle within this window must be terminated with an active ready signal. otherwise the controller hangs until the next reset. a timeout function is only provided by the watchdog timer. combining the ready function with predefined waitstates is advantageous in two cases: memory components with a fixed access time and peripherals operating with ready may be grouped into the same address window. the (external) waitstate control logic in this case would activate ready either upon the memory?s chip select or with the peripheral?s ready output. after the predefined number of waitstates the c165h will check its ready line to determine the end of the bus cycle. for a memory access it will be low already (see example a) in the figure above), for a peripheral access it may be delayed (see example b) in the figure above). as memories tend to be faster than peripherals, there should be no impact on system performance. when using the ready function with so-called ?normally-ready? peripherals, it may lead to erroneous bus cycles, if the ready line is sampled too early. these peripherals pull their ready output low, while they are idle. when they are accessed, they deactivate ready until the bus cycle is complete, then drive it low again. if, however, the peripheral deactivates ready after the first sample point of the c165h, the controller samples an active ready and terminates the current bus cycle, which, of course, is too early. by inserting predefined waitstates the first ready sample point can be shifted to a time, where the peripheral has safely controlled the ready line (eg. after 2 waitstates in the figure above).
c165h external bus interface data sheet 183 2001-04-19 p r e l i m i n a r y - exc er pt - 9.4 controlling the external bus controller a set of registers controls the functions of the ebc. general features like the usage of interface pins (wr , bhe ), segmentation are controlled via register syscon. note: for syscon register description, refer to page 66. the properties of a bus cycle like chip select mode, usage of ready , length of ale, external bus mode, read/write delay and waitstates are controlled via registers buscon4...buscon0. four of these registers (buscon4...buscon1) have an address select register (addrsel4...addrsel1) associated with them, which allows to specify up to four address areas and the individual bus characteristics within these areas. all accesses that are not covered by these four areas are then controlled via buscon0. this allows to use memory components or peripherals with different interfaces within the same system, while optimizing accesses to each of them. the layout of the five buscon registers is identical. registers buscon4...buscon1, which control the selected address windows, are completely under software control, while register buscon0, which eg. is also used for the very first code access after reset, is partly controlled by hardware, ie. it is initialized via port0 during the reset sequence. this hardware control allows to define an appropriate external bus for systems, where no internal program memory is provided.
c165h external bus interface data sheet 184 2001-04-19 p r e l i m i n a r y - exc er p t - buscon0 (ff0c h / 86 h ) sfr reset value: 0000 h buscon1 (ff14 h / 8a h ) sfr reset value: 0000 h buscon2 (ff16 h / 8b h ) sfr reset value: 0000 h buscon3 (ff18 h / 8c h ) sfr reset value: 0000 h buscon4 (ff1a h / 8d h ) sfr reset value: 0000 h note: buscon0 is initialized with 0000 h , if pin ea is high during reset. if pin ea is low bit function mctcx memory cycle time control (number of memory cycle time wait states) ? 0000 ? : 15 waitstates (number = 15 - ) . . . ? 1111 ? : no waitstates rwdcx read/write delay control for busconx ? 0 ? : with read/write delay: activate command 1 tcl after falling edge of ale ? 1 ? : no read/write delay: activate command with falling edge of ale - csw en0 csr en0 mtt c0 rwd c0 rdy en0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw rw rw - - - bus act0 rw ale ctl0 rw rw btyp mctc ew en0 - - mtt c1 rwd c1 rdy en1 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw rw btyp mctc rw - - bus act1 rw ale ctl1 rw rw csw en1 csr en1 ew en1 - - mtt c2 rwd c2 rdy en2 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw rw btyp mctc rw - - bus act2 rw ale ctl2 rw rw csw en2 csr en2 ew en2 - - mtt c3 rwd c3 rdy en3 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw rw btyp mctc rw - - bus act3 rw ale ctl3 rw rw csw en3 csr en3 ew en3 - - mtt c4 rwd c4 rdy en4 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw rw rw btyp mctc rw - - bus act4 rw ale ctl4 rw rw csw en4 csr en4 ew en4
c165h external bus interface data sheet 185 2001-04-19 p r e l i m i n a r y - exc er pt - during reset, bits busact0 and alectl0 are set (?1?) and bit field btyp is loaded with the bus configuration selected via port0. mttcx memory tristate time control ? 0 ? : 1 waitstate ? 1 ? : no waitstate ewenx early write enable bit ? 0 ? : normal write ? 1 ? : early write is enabled. the write signal turns off one tcl earlier. note: in order to have no overlapping with the following ale signal, the write control signal is shortened by one tcl by setting bit ewen. btypx external bus configuration 0 0 : 8-bit demultiplexed bus 0 1 : 8-bit multiplexed bus 1 0 : 16-bit demultiplexed bus 1 1 : 16-bit multiplexed bus note: for buscon0 btyp is defined via port0 during reset. alectlx ale lengthening control ? 0 ? : normal ale signal ? 1 ? : lengthened ale signal busactx bus active control ? 0 ? : external bus disabled ? 1 ? : external bus enabled (within the respective address window, see addrsel) rdyenx ready input enable ? 0 ? : external bus cycle is controlled by bit field mctc only ? 1 ? : external bus cycle is controlled by the ready input signal csrenx read chip select enable ? 0 ? : the cs signal is independent of the read command (rd ) ? 1 ? : the cs signal is generated for the duration of the read command cswenx write chip select enable ? 0 ? : the cs signal is independent of the write command (wr ,wrl ,wrh ) ? 1 ? : the cs signal is generated for the duration of the write command bit function
c165h external bus interface data sheet 186 2001-04-19 p r e l i m i n a r y - exc er p t - bus access control cpu accesses to internal and external busses, e.g. to internal or external memories or peripherals, are controlled with the respective address ranges. these address ranges are supported by ?chip select? functions for xbus resources or for external off-chip resources. in the c165h six address ranges with according bus definitions can be programmed for xbus peripherals (including memories) and additionally five ranges for external bus peripherals. note: in contrast to previous infineon devices the xadrs/xbcon registers are not hardwired but fully programmable. address ranges and address mapping of memories or peripherals on xbus or external bus are controlled with the address selection registers xadrsx for xbus and addrselx for external bus. the respective bus type definitions are controlled with registers xbconx and busconx. in comparison to previous devices, c165h has 3 more address selection registers for xbus:  the new register pair xadrs4 / xbcon4 use the same standard scheme of address selection and xcs control as the xadrs1-3 registers; smallest possible address range is 256 bytes.  the new register pairs xadrs5 / xbcon5 and xadrs6 / xbcon6 control address selections as defined for external peripherals (as contolled by addrsel); thus, mapping of xper addresses to the total address space is provided, with smallest possible address range of 4 k bytes. xbcon5/6 and xcs 5/6 control are identical to the standard xbus address ranges. after reset, no address selection register is selected; thus the default address range is enabled and controlled with buscon0 and additionally the chip select output cs0 is activated (as in standard c16x architecture).
c165h external bus interface data sheet 187 2001-04-19 p r e l i m i n a r y - exc er pt - addrsel1 (fe18 h / 0c h ) sfr reset value: 0000 h addrsel2 (fe1a h / 0d h ) sfr reset value: 0000 h addrsel3(fe1c h / 0e h ) sfr reset value: 0000 h addrsel4 (fe1e h / 0f h ) sfr reset value: 0000 h note: there is no register addrsel0, as register buscon0 controls all external accesses outside the four address windows of buscon4...buscon1 within the complete address space. definition of address areas the four register pairs buscon4/addrsel4...buscon1/addrsel1 allow to define 4 separate address areas within the address space of the c165h. within each of these address areas external accesses can be controlled by one of the four different bus modes, independent of each other and of the bus mode specified in register buscon0. each addrselx register in a way cuts out an address window, within which the bit function rgsz range size selection rgsad range start address 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rgsad rgsz rw 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rgsad rgsz rw 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rgsad rgsz rw 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rgsad rgsz rw
c165h external bus interface data sheet 188 2001-04-19 p r e l i m i n a r y - exc er p t - parameters in register busconx are used to control external accesses. the range start address of such a window defines the upper address bits, which are not used within the address window of the specified size (see table below). for a given window size only those upper address bits of the start address are used (marked ?r?), which are not implicitly used for addresses inside the window. the lower bits of the start address (marked ?x?) are disregarded. xadrs1(2/3/4/5/6) ( f014 h / 0a h ) esfrx reset value: 0000 h the respective sfr addresses of xadrs registers can be found in list of sfrs. due to the different range size options, address mapping of xpers is possible only within the first mbyte of the total address range if xadrs1 to xadrs4 is used. the upper four address lines (a23:a20) are set to zero. note that the range start address can be only on boundaries specified by the selected range size. bit field rgsz resulting window size relevant bits (r) of start address ( a22...a12 ) 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 x x 4 kbyte 8 kbyte 16 kbyte 32 kbyte 64 kbyte 128 kbyte 256 kbyte 512 kbyte 1mbyte 2 mbyte 4 mbyte reserved reserved. rrrrrrrrrrr rrrrrrrrrrx rrrrrrrrrx x rrrrrrrrx x x rrrrrrrxxxx rrrrrrxxxxx rrrrrxxxxxx rrrrxxxxxxx rrrxxxxxxxx rrxxxxxxxxx rxxxxxxxxxx bit function rgsad address range start address selection rgsz address range size selection 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw - - - - rgsz - rgsad
c165h external bus interface data sheet 189 2001-04-19 p r e l i m i n a r y - exc er pt - the following tables show the different definitions of range size selections and range start addresses for the two types of address selections: range size rgsz selected address range relvant(r) bits of rgsad selected range start address (relevant(r) bits of rgsad) 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 11xx 256 byte 512 bytes 1 kb 2 kb 4 kb 8 kb 16 kb 32 kb 64 kby 128 kb 256 kb 512 kb - reserved rrrr rrrr rrrr rrrr rrrr rrr0 rrrr rrrr rr00 rrrr rrrr r000 rrrr rrrr 0000 rrrr rrr0 0000 rrrr rr00 0000 rrrr r000 0000 rrrr 0000 0000 rrr0 0000 0000 rr00 0000 0000 r000 0000 0000 0000 rrrr rrrr rrrr 0000 0000 0000 rrrr rrrr rrr0 0000 0000 0000 rrrr rrrr rr00 0000 0000 0000 rrrr rrrr r000 0000 0000 0000 rrrr rrrr 0000 0000 0000 0000 rrrr rrr0 0000 0000 0000 0000 rrrr rr00 0000 0000 0000 0000 rrrr r000 0000 0000 0000 0000 rrrr 0000 0000 0000 0000 0000 rrr0 0000 0000 0000 0000 0000 rr00 0000 0000 0000 0000 0000 r000 0000 0000 0000 0000 table 25 address range and address range start definition of xadrs1/2/3/ 4 register
c165h external bus interface data sheet 190 2001-04-19 p r e l i m i n a r y - exc er p t - the xbconx registers are defined as follows: range size rgsz selected address range relvant(r) bits of rgsad selected range start address (relevant(r) bits of rgsad) 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 11xx 4 kb 8 kb 16 kb 32 kb 64 kb 128 kb 256 kb 512 kb 1 mb 2 mb 4 mb 8 mb - reserved rrrr rrrr rrrr rrrr rrrr rrr0 rrrr rrrr rr00 rrrr rrrr r000 rrrr rrrr 0000 rrrr rrr0 0000 rrrr rr00 0000 rrrr r000 0000 rrrr 0000 0000 rrr0 0000 0000 rr00 0000 0000 r000 0000 0000 rrrr rrrr rrrr 0000 0000 0000 rrrr rrrr rrr0 0000 0000 0000 rrrr rrrr rr00 0000 0000 0000 rrrr rrrr r000 0000 0000 0000 rrrr rrrr 0000 0000 0000 0000 rrrr rrr0 0000 0000 0000 0000 rrrr rr00 0000 0000 0000 0000 rrrr r000 0000 0000 0000 0000 rrrr 0000 0000 0000 0000 0000 rrr0 0000 0000 0000 0000 0000 rr00 0000 0000 0000 0000 0000 r000 0000 0000 0000 0000 0000 table 26 address range and address range start definition of xadrs5/6 register
c165h external bus interface data sheet 191 2001-04-19 p r e l i m i n a r y - exc er pt - xbcon1/2/3 ( f114 h / 8a h ) esfr-b reset value: 0000 h note: the ?buscon switch control? bswc is a new function, which is necessary due to the execution with higher frequencies, to avoid bus collisions on data bus in case of peripheral change (see buscon). note: all xadrsx/addrselx registers as well as xbconx/busconx registers are user programmable sfr registers. all busconx registers are mapped into the bitaddressable sfr memory space, all xbconx registers are located in the bitaddressable esfr memory space. although they are free programmable, bit function mctcx memory cycle time control (see buscon) rwdcx read/write delay control (see buscon) mttcx memory tri-state time control (see buscon) btypx bus type selection ; only demultiplexed busses are supported on xbus; ? 00 ? : 8 bit bus ? 10 ? : 16 bit bus; ? x1 ? : reserved. ewenx early write enable ? 0 ? : standard write enable signal control ? 1 ? : write active state is disabled one tcl e arlier alectlx ale lengthening control bit (see buscon) busactx* bus active control ?0?: xbus (peripheral) disabled ?1?: xbus (peripheral) enabled enables the xbus and the according chip select xcsx for the respective address window (respective xbus peripheral), selected with according xadrsx window; after reset, all address windows on xbus are disabled. *not used in fc-cores, where xbcon is hardwired. bswcx buscon switch control ? 0 ? : standard switch of bustype (switch of xbcon) ? 1 ? : a bus wait state (tri-state cycle) is included after execution of last old- bustype cycle and before the first new-bustype cycle after switch of xbcon or buscon; the bswc bit is indicated in the old-bustype xbcon/buscon. rdyenx ready enable ? 0 ? : the bus cycle length is controlled by the bus controller using mctc ? 1 ? : the bus cycle length is controlled by the peripheral using ready bs wcx - - - rdy enx bus actx ale ctlx ew enx mt tcx rw dcx 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw - - - rw mctcx rw rw rw btypx rw
c165h external bus interface data sheet 192 2001-04-19 p r e l i m i n a r y - exc er p t - programming should be performed during the initialisation phase before the first accesses are controlled with xbconx or busconx. note: the respective sfr addresses of xbcon registers can be found in list of sfrs. note: within the c165h, register xbcon1 is related to the iom-2 module. for configuration, please also refer to chapter 9.8, "initialization of the c165h?s x- peripherals" on page 199. address window arbitration for each access the ebc compares the current address with all address select registers (programmable addrselx and hardwired xadrsx). this comparison is done in four levels. priority 1 : the xadrsx registers are evaluated first. a match with one of these registers directs the access to the respective x-peripheral using the corresponding xbconx register and ignoring all other addrselx registers. priority 2 : registers addrsel2 and addrsel4 are evaluated before addrsel1 and addrsel3, respectively. a match with one of these registers directs the access to the respective external area using the corresponding busconx register and ignoring registers addrsel1/3 (see figure below). priority 3 : a match with registers addrsel1 or addrsel3 directs the access to the respective external area using the corresponding busconx register. priority 4 : if there is no match with any xadrsx or addrselx register the access to the external bus uses register buscon0. figure 53 address window arbitration note: only the indicated overlaps are defined. all other overlaps lead to erroneous bus cycles. eg. addrsel4 may not overlap addrsel2 or addrsel1. the hardwired xadrsx registers are defined non-overlapping. active window inactive window buscon0 buscon1 buscon2 xbcon0 buscon3 buscon4
c165h external bus interface data sheet 193 2001-04-19 p r e l i m i n a r y - exc er pt - rp0h (f108 h / 84 h ) sfr reset value: - - xx h note: rp0h cannot be changed via software, but rather allows to check the current configuration. precautions and hints  the external bus interface is enabled as long as at least one of the buscon registers has its busact bit set.  port1 will output the intra-segment address as long as at least one of the buscon registers selects a demultiplexed external bus, even for multiplexed bus cycles.  not all address areas defined via registers addrselx may overlap each other. the operation of the ebc will be unpredictable in such a case. see chapter ?address window arbitration?.  the address areas defined via registers addrselx may overlap internal address areas. internal accesses will be executed in this case.  for any access to an internal address area the ebc will remain inactive (see ebc idle state). bit function wrc write configuration 0: pins wr and bhe operate as wrl and wrh signals 1: pins wr and bhe operate as wr and bhe signals cssel chip select line selection (number of active cs outputs) 0 0: 3 cs lines: cs 2...cs 0 0 1: 2 cs lines: cs 1...cs 0 1 0: no cs lines at all 1 1: 5 cs lines: cs 4...cs 0 (default without pulldowns) salsel segment address line selection (number of active segment address outputs) 0 0: 4-bit segment address: a19...a16 0 1: no segment address lines at all 1 0: 7-bit segment address: a22...a16 1 1: 2-bit segment address: a17...a16 (default without pulldowns) clkcfg clock generation mode configuration these pins define the clock generation mode, ie. the mechanism how the the internal cpu clock is generated from the externally applied (xtal1) input clock. wrc 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 r r - - - - r - - - - cssel salsel r clkcfg
c165h external bus interface data sheet 194 2001-04-19 p r e l i m i n a r y - exc er p t - 9.5 ebc idle state when the external bus interface is enabled, but no external access is currently executed, the ebc is idle. as long as only internal resources (from an architecture point of view) like iram, gprs or sfrs, etc. are used the external bus interface does not change (see table below). accesses to on-chip x-peripherals are also controlled by the ebc. however, even though an x-peripheral appears like an external peripheral to the controller, the respective accesses do not generate valid external bus cycles. due to timing constraints address and write data of an xbus cycle are reflected on the external bus interface (see table below). the ?address? mentioned above includes port1, port 4, bhe and ale which also pulses for an xbus cycle. the external cs signals on port 6 are driven inactive (high) because the ebc switches to an internal xcs signal. the external control signals (rd and wr or wrl /wrh if enabled) remain inactive (high). table 27 status of the external bus interface during ebc idle state: 9.6 external bus arbitration in high performance systems it may be efficient to share external resources like memory banks or peripheral devices among more than one controller. the c165h supports this approach with the possibility to arbitrate the access to its external bus, ie. to the external devices. pins internal accesses only xbus accesses port0 tristated (floating) tristated (floating) for read accesses xbus write data for write accesses port1 last used external address (if used for the bus interface) last used xbus address (if used for the bus interface) port 4 last used external segment address (on selected pins) last used xbus segment address (on selected pins) port 6 active external cs signal corresponding to last used address inactive (high) for selected cs signals bhe level corresponding to last external access level corresponding to last xbus access ale inactive (low) pulses as defined for x-peripheral rd inactive (high) inactive (high) wr /wrl inactive (high) inactive (high) wrh inactive (high) inactive (high)
c165h external bus interface data sheet 195 2001-04-19 p r e l i m i n a r y - exc er pt - this bus arbitration allows an external master to request the c165h?s bus via the hold input. the c165h acknowledges this request via the hlda output and will float its bus lines in this case. the cs outputs provide internal pullup devices. the new master may now access the peripheral devices or memory banks via the same interface lines as the c165h. during this time the c165h can keep on executing, as long as it does not need access to the external bus. all actions that just require internal resources like instruction or data memory and on-chip peripherals, may be executed in parallel. when the c165h needs access to its external bus while it is occupied by another bus master, it demands it via the breq output. the external bus arbitration is enabled by setting bit hlden in register psw to ?1?. in this case the three bus arbitration pins hold , hlda and breq are automatically controlled by the ebc independent of their i/o configuration. bit hlden may be cleared during the execution of program sequences, where the external resources are required but cannot be shared with other bus masters. in this case the c165h will not answer to hold requests from other external masters. if hlden is cleared while the c165h is in hold state (code execution from internal ram) this hold state is left only after hold has been deactivated again. ie. in this case the current hold state continues and only the next hold request is not answered. connecting eg. two c165hs in this way would require additional logic to combine the respective output signals hlda and breq . this can be avoided by switching one of the controllers into slave mode where pin hlda is switched to input. this allows to directly connect the slave controller to another master controller without glue logic. the slave mode is selected by setting bit dp6.7 to ?1?. dp6.7=?0? (default after reset) selects the master mode. note: the pins hold , hlda and breq keep their alternate function (bus arbitration) even after the arbitration mechanism has been switched off by clearing hlden. all three pins are used for bus arbitration after bit hlden was set once. connecting bus masters when multiple c165hs or a c165h and another bus master shall share external resources some glue logic is required that defines the currently active bus master and also enables a c165h which has surrendered its bus interface to regain control of it in case it must access the shared external resources. this glue logic is required if the ?other? bus master does not automatically remove its hold request after having used the shared resources. when two c165hs are to be connected in this way the external glue logic can be left out. in this case one of the controllers must be operated in its master mode (default after reset, dp6.7=?0?) while the other one must be operated in its slave mode (selected with dp6.7=?1?).
c165h external bus interface data sheet 196 2001-04-19 p r e l i m i n a r y - exc er p t - in slave mode the c165h inverts the direction of its hlda pin and uses it as an input, while the master?s hlda pin remains an output. this approach does not require any additional glue logic for the bus arbitration (see figure below). figure 54 sharing external resources using slave mode when the bus arbitration is enabled (hlden=?1?) the three corresponding pins are automatically controlled by the ebc. normally the respective port direction register bits retain their reset value which is ?0?. this selects master mode where the device operates compatible with earlier versions. slave mode is enabled by intentionally switching pin breq to output (dp6.7=?1?) which is neither required for master mode nor for earlier devices. entering the hold state access to the c165h?s external bus is requested by driving its hold input low. after synchronizing this signal the c165h will complete a current external bus cycle (if any is active), release the external bus and grant access to it by driving the hlda output low. during hold state the c165h treats the external bus interface as follows:  address and data bus(es) float to tri-state  ale is pulled low by an internal pulldown device  command lines are pulled high by internal pullup devices (rd , wr /wrl , bhe /wrh )  csx outputs are pulled high (push/pull mode) or float to tri-state (open drain mode) should the c165h require access to its external bus during hold mode, it activates its bus request output breq to notify the arbitration circuitry. breq is activated only during hold mode. it will be inactive during normal operation. c165h in master mode breq hlda hold c165h in slave mode breq hlda hold
c165h external bus interface data sheet 197 2001-04-19 p r e l i m i n a r y - exc er pt - figure 55 external bus arbitration, releasing the bus note: the c165h will complete the currently running bus cycle before granting bus access as indicated by the broken lines. this may delay hold acknowledge compared to this figure. the figure above shows the first possibility for breq to get active. during bus hold pin p3.12 is switched back to its standard function and is then controlled by dp3.12 and p3.12. keep dp3.12 = ?0? in this case to ensure floating in hold mode. exiting the hold state the external bus master returns the access rights to the c165h by driving the hold input high. after synchronizing this signal the c165h will drive the hlda output high, actively drive the control signals and resume executing external bus cycles if required. depending on the arbitration logic, the external bus can be returned to the c165h under two circumstances:  the external master does no more require access to the shared resources and gives up its own access rights, or  the c165h needs access to the shared resources and demands this by activating its breq output. the arbitration logic may then deactivate the other master?s hlda and so free the external bus for the c165h, depending on the priority of the different masters. note: the hold state is not terminated by clearing bit hlden. mcd02238 hold hlda breq csx ~ ~~ ~~ ~~ ~~ ~ signals ~ ~ ~ ~ other
c165h external bus interface data sheet 198 2001-04-19 p r e l i m i n a r y - exc er p t - figure 56 external bus arbitration, (regaining the bus) note: the falling breq edge shows the last chance for breq to trigger the indicated regain-sequence. even if breq is activated earlier the regain-sequence is initiated by hold going high. breq and hold are connected via an external arbitration circuitry. please note that hold may also be deactivated without the c165h requesting the bus. 9.7 xbus interface the c165h provides an on-chip interface (the xbus interface), which allows to connect integrated customer/application specific peripherals to the standard controller core. the xbus is an internal representation of the external bus interface, ie. it is operated in the same way. the current xbus interface is prepared to support up to 3 x-peripherals. for each peripheral on the xbus (x-peripheral) there is a separate address window controlled by an xbcon and an xadrs register. as an interface to a peripheral in many cases is represented by just a few registers, the xadrs registers select smaller address windows than the standard addrsel registers. as the register pairs control integrated peripherals rather than externally connected ones, they are fixed by mask programming rather than being user programmable. mcd02236 other signals csx breq hlda hold
c165h external bus interface data sheet 199 2001-04-19 p r e l i m i n a r y - exc er pt - x-peripheral accesses provide the same choices as external accesses, so these peripherals may be bytewide or wordwide, with or without a separate address bus. interrupt nodes and configuration pins (on port0) are provided for x-peripherals to be integrated. 9.8 initialization of the c165h?s x-peripherals the following registers must be set for initialization of the c165h x-peripherals: xpercon-register (addr. f024, default: 0000): bit 5: '1': iom-2 active '0': iom-2 switched-off syscon-register (addr. ff12, default: 0xx0): bit 2: '1': x-peripherals enable '0': x-peripherals disable bit 1: '1': x-per accesses visible at externalxbus'0': x-per accesses not visible syscon3-register (addr. f1d4, default: 0000): bit 15: '1': all peripheral clocks disabled '0': individual disable control by bits 14 thru 0 bit 6: '1': disable iom-2 clock '0': enable iom-2 clock bit 3: '1': disable gpt12 clock '0': enable gpt12 clock bit 2: '1': disable ssc clock '0': enable ssc clock bit 1: '1': disable asc clock '0': enable asc clock bit 0: '1': disable rtc clock '0': enable rtc clock xbcon1-register (addr.f114, default: 0000 h ): definition of the iom-2 bus protocol. must be set to ?048x h ?. recommended using 0 waitstates: ?048f h ?. xbcon2-register (addr.f116, default: 0000 h ): this register is not used. must be set to ?0000 h ?. xbcon3-register (addr.f118, default: 0000 h ): this register is not used. must be set to ?0000 h ?. xadrs1-register (addr.f014, default: uuuu): definition of the iom-2 address space. should be initialized with ?0ef0 h ? before writing to xbcon1.
c165h general purpose timer unit data sheet 200 2001-04-19 p r e l i m i n a r y - exc er p t - 10 general purpose timer unit the general purpose timer unit (gpt) represents very flexible multifunctional timer structures which may be used for timing, event counting, pulse width measurement, pulse generation, frequency multiplication, and other purposes. in the c165h, there are following alternate function pins available: p3.3/t3out, p3.5/ t4in/t3eud/t2eud, p3.6/t3in and p3.7/t2in, as shown in figure 57 . figure 57 gpt module external pins gpt1 core timer 3 gpt1 core timer 4 gpt2 core timer 5 gpt1 core timer 2 gpt2 core timer 6 p3.6 p3.7 p3.5 t2in t2eud t3in t3eud t4in p3.3 t3out gpt12utahimpl t3otl interrupt request t2ic.t2ir interrupt request t4ic.t4ir interrupt request t5ic.t5ir interrupt request t6ic.t6ir interrupt request t3ic.t3ir t6otl gpt2 caprel interrupt request cric.crir note: in the c165h, there are no external pins connected to timer 5 and timer 6. additional, there is no second external connection to timer 4 (t4eud) and no external connection to the register gpt2 caprel.
c165h general purpose timer unit data sheet 201 2001-04-19 p r e l i m i n a r y - exc er pt - the gpt incorporate five 16-bit timers that are grouped into the two timer blocks gpt1 and gpt2. each timer in each block may operate independently in a number of different modes such as gated timer or counter mode, or may be concatenated with another timer of the same block. block 1 contains 3 timers/counters with a maximum resolution of f timer /4. the auxiliary timers of gpt1 may optionally be configured as reload or capture registers for the core timer. block 2 contains 2 internal timers/counters with a maximum resolution of f timer /2. an additional caprel register supports capture and reload operation with extended functionality. the following enumeration summarizes all features to be supported:  timer block 1: ?f timer /4 maximum resolution. ? 3 independent timers/counters. ? timers/counters can be concatenated. ? 4 operating modes (timer, gated timer, counter, incremental). ? separate interrupt nodes.  timer block 2: ?f timer /2 maximum resolution. ? 2 independent timers/counters. ? timers/counters can be concatenated. ? 2 operating modes (timer, counter). ? capture/reload functions via 16-bit capture/reload register caprel. ? separate interrupt nodes. 10.1 kernel description 10.1.1 functional description of timer block 1 all three timers of block 1 (t2, t3, t4) can run in 4 basic modes, which are timer, gated timer, counter and incremental interface mode, and all timers can either count up or down. the input line (txin) associated with it which serves as the gate control in gated timer mode, or as the count input in counter mode. the count direction (up / down) may be programmed via software or may be dynamically altered by a signal at an external control input line. an overflow/underflow of core timer t3 is indicated by the output toggle latch t3otl whose state may be output on related line t3out.
c165h general purpose timer unit data sheet 202 2001-04-19 p r e l i m i n a r y - exc er p t - the auxiliary timers t2 and t4 may additionally be concatenated with the core timer, or used as capture or reload registers for the core timer. the current contents of each timer can be read or modified by the cpu by accessing the corresponding timer registers t2, t3, or t4, which are located in the non-bitaddressable sfr space. when any of the timer registers is written to by the cpu in the state immediately before a timer increment, decrement, reload, or capture is to be performed, the cpu write operation has priority in order to guarantee correct results. figure 58 structure of timer block 1 10.1.1.1 core timer t3 the operation of the core timer t3 is controlled by its bitaddressable control register t3con. t3 mode control 2 n : 1 2 n : 1 f hw_clk t2 mode control gpt1 timer t2 reload capture 2 n : 1 t4 mode control gpt1 timer t4 reload capture gpt1 timer t3 t3otl u/d t2eud t2in t3in t3eud t4in t3out toggle ff u/d u/d interrupt request interrupt request interrupt request mct02141 f hw_clk f hw_clk t3otl t3otl
c165h general purpose timer unit data sheet 203 2001-04-19 p r e l i m i n a r y - exc er pt - run control the timer can be started or stopped by software through bit t3r (timer t3 run bit). setting bit t3r to ?1? will start the timer, clearing t3r stops the timer. in gated timer mode, the timer will only run if t3r = ?1? and the gate is active (high or low, as programmed). note: when bit t2rc/t4rc in timer control register t2con/t4con is set to ?1?, t3r will also control (start and stop) auxiliary timer t2/t4. count direction control the count direction of the core timer can be controlled either by software or by the external input line t3eud (timer t3 external up/down control input). these options are selected by bits t3ud and t3ude in control register t3con. when the up/down control is done by software (bit t3ude = ?0?), the count direction can be altered by setting or clearing bit t3ud. when t3ude = ?1?, line t3eud is selected to be the controlling source of the count direction. however, bit t3ud can still be used to reverse the actual count direction, as shown in the table below. if t3ud = ?0? and line t3eud shows a low level, the timer is counting up. with a high level at t3eud the timer is counting down. if t3ud = ?1?, a high level at line t3eud specifies counting up, and a low level specifies counting down. the count direction can be changed regardless of whether the timer is running or not. when line t3eud is used as external count direction control input, its associated port pin must be configured as input. note: the direction control works the same for core timer t3 and for auxiliary timer t2. for timer t4, no t4eud input exist, therefore the count direction can be controlled by software only. table 28 gpt1 core timer t3 count direction control line txeud bit txude bit txud count direction x 0 0 count up x 0 1 count down 0 1 0 count up 1 1 0 count down 0 1 1 count down 1 1 1 count up
c165h general purpose timer unit data sheet 204 2001-04-19 p r e l i m i n a r y - exc er p t - timer 3 overflow/underflow monitoring an overflow or underflow of timer t3 will clock the overflow toggle latch t3otl in control register t3con. t3otl can also be set or reset by software. bit t3oe (overflow/ underflow output enable) in register t3con enables the state of t3otl to be monitored via an external line t3out. if this line is linked to an external port pin, which has to be configured as output, t3otl can be used to control external hw. in addition, t3otl can be used in conjunction with the timer over/underflows as an input for the counter function or as a trigger source for the reload function of the auxiliary timers t2 and t4. for this purpose, the state of t3otl does not have to be available at any port pin, because an internal connection is provided for this option. timer 3 in timer mode timer mode for the core timer t3 is selected by setting bit field t3m in register t3con to ?000 b ?. in this mode, t3 is clocked with the module clock f timer divided by a programmable prescaler, which is controlled by bit field t3i and bit fm1. the input frequency f t3 for timer t3 and its resolution r t3 are scaled linearly with lower module clock frequencies, as can be seen from the following formula: this formula also applies to the gated timer mode of t3 and to the auxiliary timers t2 and t4 in timer and gated timer mode, where applicable. table 29 example for timer 3 frequencies and resolutions f timer [mhz] t3i fm1 f t3 [khz] r t3 [ s] 24 ?111? 0 23.44 42.67 24 ?000? 1 6000.0 0.17 36 ?000? 0 4500.0 0.22 36 ?100? 0 281.25 3.55 36 ?111? 1 70.31 14.22 f t3 = f timer 8 * 2 r t3 [ s] = f timer [mhz] 8 * 2
c165h general purpose timer unit data sheet 205 2001-04-19 p r e l i m i n a r y - exc er pt - figure 59 block diagram of core timer t3 in timer mode timer 3 in gated timer mode gated timer mode for the core timer t3 is selected by setting bit field t3m in register t3con to ?010 b ? or ?011 b ?. bit t3m.0 (t3con.3) selects the active level of the gate input. in gated timer mode the same options for the input frequency as for the timer mode are available. however, the input clock to the timer in this mode is gated by the external input line t3in (timer t3 external input), which is an alternate function of p3.6. to enable this operation pin p3.6/t3in must be configured as input, ie. direction control bit dp3.6 must contain ?0?. core timer tx txotl interrupt request txr 2 n : 1 txl up/ down txude mcb02028 f hw_clk txud x=3
c165h general purpose timer unit data sheet 206 2001-04-19 p r e l i m i n a r y - exc er p t - figure 60 block diagram of core timer t3 in gated timer mode if t3m = ?010 b ?, the timer is enabled when t3in shows a low level. a high level at this line stops the timer. if t3m = ?011 b ?, line t3in must have a high level in order to enable the timer. in addition, the timer can be turned on or off by software using bit t3r. the timer will only run, if t3r = ?1? and the gate is active. it will stop, if either t3r = ?0? or the gate is inactive. note: a transition of the gate signal at line t3in does not cause an interrupt request. timer 3 in counter mode counter mode for the core timer t3 is selected by setting bit field t3m in register t3con to ?001 b ?. in counter mode timer t3 is clocked by a transition at the external input pin t3in, which is an alternate function of p3.6. the event causing an increment or decrement of the timer can be a positive, a negative, or both a positive and a negative transition at this line. bit field t3i in control register t3con selects the triggering transition (see table 30 below). core tim er tx txotl interrupt request txoe txout txr mux xor 0 mux 1 up/ down txeud txude mcb02029 txud 2 n : 1 txi f hw_clk txm txin x=3
c165h general purpose timer unit data sheet 207 2001-04-19 p r e l i m i n a r y - exc er pt - figure 61 block diagram of core timer t3 in counter mode table 30 core timer t3 (counter mode) input edge selection for counter operation, a port pin p3.6/t3in must be configured as input. the maximum input frequency which is allowed in counter mode is f timer /8 (fm1 = ?1?). to ensure that a transition of the count input signal which is applied to t3in is correctly recognized, its level should be held high or low for at least 4 f timer cycles (fm1 = ?1?) before it changes. timer 3 in incremental interface mode incremental interface mode for the core timer t3 is selected by setting bit field t3m in register t3con to ?110 b ? or ?111 b ?. in incremental interface mode pin p3.6/t3in (configured as timer input t3in) and pin p3.5/t3eud (configured as timer input) are used to interface to an incremental encoder. note: in the c165h, the t3eud timer input is connected to p3.5. in this case, timer 4 input t4in can be used by software only. t3i triggering edge for counter increment / decrement 0 0 0 none. counter t3 is disabled 0 0 1 positive transition (rising edge) on t3in 0 1 0 negative transition (falling edge) on t3in 0 1 1 any transition (rising or falling edge) on t3in 1 x x reserved. do not use this combination core timer tx txr xor 0 mux 1 up/ down txeud txude mcb02030 txl txin edge select txotl interrupt request txoe txout txud x=3
c165h general purpose timer unit data sheet 208 2001-04-19 p r e l i m i n a r y - exc er p t - t3 is clocked by each transition on one or both of the external input lines which gives 2- fold or 4-fold resolution of the encoder input. figure 62 block diagram of core timer t3 in incremental interface mode bit field t3i in control register t3con selects the triggering transitions (see table below). in this mode the sequence of the transitions of the two input signals is evaluated and generates count pulses as well as the direction signal. depending on the chosen incremental intrerface mode, rotation detection ?110 b ? or edge detection ?111 b ?, an interrupt can be generated. this interrupt is only generated if it?s enabled by setting bit t3iren in register t3con. for the rotation detection an interrupt will be generated each time the count direction of timer 3 changes. for the edge detection an interrupt will be generated each time a count action for timer 3 occurs. count direction, changes in the count direction and count requests are monitored through the status bits t3rdir, t3chdir and t3edge in register t3con. t3 is modified automatically according to the speed and the direction of the incremental encoder. therefore, the contents of timer t3 always represents the encoder?s current position. table 31 core timer t3 (incremental interface mode) input edge selection t3i triggering edge for counter increment / decrement 0 0 0 none. counter t3 stops. 0 0 1 any transition (rising or falling edge) on t3in. 0 1 0 any transition (rising or falling edge) on t3eud. edge select timer t3 xor mux t3eud t3ude mcb03998 t3l t3in t3otl interrupt request t3out phase detect t3oe t3r edge interrupt t3 edge t3ud t3 chdir 0 1 change detection t3 rdir rotation interrupt t3m up/ down t3m
c165h general purpose timer unit data sheet 209 2001-04-19 p r e l i m i n a r y - exc er pt - the incremental encoder can be connected directly to the microcontroller without external interface logic. in a standard system, however, comparators will be employed to convert the encoder?s differential outputs (e.g. a, a ) to digital signals (e.g. a). this greatly increases noise immunity. note: the third encoder output t0, which indicates the mechanical zero position, may be connected to an external interrupt input and trigger a reset of timer t3. figure 63 interfacing the encoder to the microcontroller for incremental interface operation the following conditions must be met: l bitfield t3m must be ?110 b ? or ?111 b ?. l pins associated to lines t3in and t3eud must be configured as input. l bit t3ude must be ?1? to enable automatic direction control. the maximum input frequency which is allowed in incremental interface mode is f timer /8 (fm = 1). to ensure that a transition of any input signal is correctly recognized, its level should be held high or low for at least 4 f timer cycles (fm = 1) before it changes. in incremental interface mode the count direction is automatically derived from the sequence in which the input signals change, which corresponds to the rotation direction of the connected sensor. the table below summarizes the possible combinations. the figures below give examples of t3?s operation, visualizing count signal generation and direction control. it also shows how input jitter is compensated which might occur if the sensor rests near to one of its switching points. 0 1 1 any transition (rising or falling edge) on any t3 input (t3in or t3eud). 1 x x reserved. do not use this combination table 31 core timer t3 (incremental interface mode) input edge selection t3i triggering edge for counter increment / decrement a a b b t0 t0 a b t0 external t3input t3input interrup t encoder signal conditioning + - + - + - micro- controller
c165h general purpose timer unit data sheet 210 2001-04-19 p r e l i m i n a r y - exc er p t - figure 64 evaluation of the incremental encoder signals table 32 core timer t3 (incremental interface mode) count direction level on respective other input t3in input t3eud input rising falling rising falling high down up up down low up down down up t3in t3eud contents of t3 forward forward backward jitter jitter up down up note: this example shows the timer behavior assuming that t3 counts upon any transition on any input, i.e. t3i = ?011 b ?.
c165h general purpose timer unit data sheet 211 2001-04-19 p r e l i m i n a r y - exc er pt - figure 65 evaluation of the incremental encoder signals note: timer t3 operating in incremental interface mode automatically provides information on the sensor?s current position. dynamic information (speed, acceleration, deceleration) may be obtained by measuring the incoming signal periods. 10.1.1.2 auxiliary timers t2 and t4 note: for the external pin connection of the timer t2 and timer t4, please refer to figure 57 , page 200. both auxiliary timers t2 and t4 have exactly the same functionality with the only restriction of the availibility of external pins connected to each timer. timer t2 can be configured for timer, gated timer, counter, or incremental interface mode. timer t4 can be configured for timer, gated timer and counter mode. in addition, the auxiliary timers can be concatenated with the core timer, or they may be used as reload or capture registers in conjunction with the core timer. note: timer 2 input t2eud is connected to p3.5. when the external input for t2eud is used (p3.5 configured as input), t4in and t3eud can be used by software (internal) only. the individual configuration for timers t2 and t4 is determined by their bitaddressable control registers t2con and t4con, which are both organized identically. note that functions which are present in all 3 timers of timer block 1 are controlled in the same bit positions and in the same manner in each of the specific control registers. t3in t3eud contents of t3 forward forward backward jitter jitter up down u p note: this example shows the timer behavior assuming that t3 counts upon any transition on input t3in, i.e. t3i = ?001 b ?.
c165h general purpose timer unit data sheet 212 2001-04-19 p r e l i m i n a r y - exc er p t - run control for auxiliary timers t2 and t4 can be handled by the associated run control bit t2r, t4r in register t2con/t4con. alternatively, a remote control option (t2rc, t4rc = ?1?) may be enabled to start and stop t2/t4 via the run bit t3r of core timer t3. timers t2 and t4 in timer mode or gated timer mode when the auxiliary timers t2 and t4 are programmed to timer mode or gated timer mode, their operation is the same as described for the core timer t3. the descriptions, figures and tables apply accordingly with two exceptions:  there is no txout output line for t2 and t4.  there is no t4eud input. therefore software must be programmed accordingly.  overflow/underflow monitoring is not supported (no output toggle latch). timer t2 in counter mode in counter mode timer t2 can be clocked either by a transition at the respective external input line t2in, or by a transition of timer t3?s output toggle latch t3otl. figure 66 block diagram of the auxiliary timer t2 in counter mode the event causing an increment or decrement of the timer t2 can be a positive, a negative, or both a positive and a negative transition at either the input line, or at the output toggle latch t3otl. bit field t2i in the respective control register t2con selects the triggering transition (see table below). auxiliary timer t2 interrupt request t2r up/ down t2ud t2ude mcb02221utah t2l t2in/ t3otl edge select
c165h general purpose timer unit data sheet 213 2001-04-19 p r e l i m i n a r y - exc er pt - note: only state transitions of t3otl which are caused by the overflows/underflows of t3 will trigger the counter function of t2. modifications of t3otl via software will not trigger the counter function of t2. for counter operation, an external pin associated to line t2in must be configured as input. the maximum input frequency which is allowed in counter mode is f timer /8 (fm1 = ?1?). to ensure that a transition of the count input signal which is applied to t2in is correctly recognized, its level should be held for at least 4 f timer cycles (fm1 = ?1?) before it changes. timer t4 in counter mode the operation of timer t4 in counter mode is exactly the same as described for timer t2 in chapter "timer t2 in counter mode" above. 10.1.1.3 timer concatenation using the output toggle latch t3otl as a clock source for an auxiliary timer in counter mode concatenates the core timer t3 with the respective auxiliary timer. depending on which transition of t3otl is selected to clock the auxiliary timer, this concatenation forms a 32-bit or a 33-bit timer/counter.  32-bit timer/counter : if both a positive and a negative transition of t3otl is used to clock the auxiliary timer, this timer is clocked on every overflow/underflow of the core timer t3. thus, the two timers form a 32-bit timer.  33-bit timer/counter : if either a positive or a negative transition of t3otl is selected to clock the auxiliary timer, this timer is clocked on every second overflow/underflow of the core timer t3. this configuration forms a 33-bit timer (16-bit core timer+t3otl+16-bit auxiliary timer). table 33 auxiliary timer t2 (counter mode) input edge selection t2i triggering edge for counter increment / decrement x 0 0 none. counter t2 is disabled 0 0 1 positive transition (rising edge) on t2in 0 1 0 negative transition (falling edge) on t2in 0 1 1 any transition (rising or falling edge) on t2in 1 0 1 positive transition (rising edge) of output toggle latch t3otl 1 1 0 negative transition (falling edge) of output toggle latch t3otl 1 1 1 any transition (rising or falling edge) of output toggle latch t3otl
c165h general purpose timer unit data sheet 214 2001-04-19 p r e l i m i n a r y - exc er p t - the count directions of the two concatenated timers are not required to be the same. this offers a wide variety of different configurations. t3 can operate in timer, gated timer or counter mode in this case. figure 67 concatenation of core timer t3 and an auxiliary timer auxiliary timer in reload mode reload mode for the auxiliary timers t2 and t4 is selected by setting bit field txm in the respective register txcon to ?100 b ?. in reload mode the core timer t3 is reloaded with the contents of an auxiliary timer register, triggered by one of two different signals. the trigger signal is selected the same way as the clock source for counter mode (see table above), i.e. a transition of the auxiliary timer?s input or the output toggle latch t3otl may trigger the reload. note: when programmed for reload mode, the respective auxiliary timer (t2 or t4) stops independent of its run flag t2r or t4r. core timer t3 t3otl interrupt request t3r 2 n : 1 t3l mcb02034gpt1 f hw_clk up/down auxiliary timer tx txr txl edge select txir interrupt request *) t3oe t3out note: line ?*? only affected by over/underflows of t3, but not by software modifications of t3otl. x = 2,4
c165h general purpose timer unit data sheet 215 2001-04-19 p r e l i m i n a r y - exc er pt - figure 68 gpt1 auxiliary timer in reload mode upon a trigger signal t3 is loaded with the contents of the respective timer register (t2 or t4) and the interrupt request flag (t2ir or t4ir) is set. note: when a t3otl transition is selected for the trigger signal, also the interrupt request flag t3ir will be set upon a trigger, indicating t3?s overflow or underflow. modifications of t3otl via software will not trigger the counter function of t2/t4. the reload mode triggered by t3otl can be used in a number of different configurations. depending on the selected active transition the following functions can be performed:  if both a positive and a negative transition of t3otl is selected to trigger a reload, the core timer will be reloaded with the contents of the auxiliary timer each time it overflows or underflows. this is the standard reload mode (reload on overflow/ underflow).  if either a positive or a negative transition of t3otl is selected to trigger a reload, the core timer will be reloaded with the contents of the auxiliary timer on every second overflow or underflow.  using this ?single-transition? mode for both auxiliary timers allows to perform very flexible pulse width modulation (pwm). one of the auxiliary timers is programmed to reload the core timer on a positive transition of t3otl, the other is programmed for a reload register tx core timer t3 up/down source/edge select t3otl interrupt request t3oe t3out txin input clock txi *) interrupt request mcb02035utah note: line ?*? only x = (2, 4)
c165h general purpose timer unit data sheet 216 2001-04-19 p r e l i m i n a r y - exc er p t - reload on a negative transition of t3otl. with this combination the core timer is alternately reloaded from the two auxiliary timers. the figure below shows an example for the generation of a pwm signal using the alternate reload mechanism. t2 defines the high time of the pwm signal (reloaded on positive transitions) and t4 defines the low time of the pwm signal (reloaded on negative transitions). the pwm signal can be output on line t3out if the control bit t3oe is set to ?1?. with this method the high and low time of the pwm signal can be varied in a wide range. note: the output toggle latch t3otl is accessible via software and may be changed, if required, to modify the pwm signal. however, this will not trigger the reloading of t3. note: an associated port pin linked to line t3out should be configured as output. figure 69 gpt1 timer reload configuration for pwm generation c ore tim er t3 up/down t3otl interrupt request t3oe t3out interrupt request reload register t2 interrupt request reload register t4 t2i *) *) t4i input clock mcb02037 note: lines ?*? only affected by over/underflows of t3, but not by software modifications of t3otl.
c165h general purpose timer unit data sheet 217 2001-04-19 p r e l i m i n a r y - exc er pt - note: although it is possible, it should be avoided to select the same reload trigger event for both auxiliary timers. in this case both reload registers would try to load the core timer at the same time. if this combination is selected, t2 is disregarded and the contents of t4 is reloaded. auxiliary timer in capture mode capture mode for the auxiliary timers t2 and t4 is selected by setting bit field txm in the respective register txcon to ?101 b ?. in capture mode the contents of the core timer are latched into an auxiliary timer register in response to a signal transition at the respective auxiliary timer's external input line txin. the capture trigger signal can be a positive, a negative, or both a positive and a negative transition. the two least significant bits of bit field txi are used to select the active transition (see table in the counter mode section), while the most significant bit txi.2 is irrelevant for capture mode. it is recommended to keep this bit cleared (txi.2 = ?0?). note: when programmed for capture mode, the respective auxiliary timer (t2 or t4) stops independent of its run flag t2r or t4r. figure 70 auxiliary timer of timer block 1 in capture mode upon a trigger (selected transition) at the corresponding input line txin the contents of the core timer are loaded into the auxiliary timer register and the associated interrupt request flag txir will be set. capture register tx core tim er t3 up/down edge select t3otl interrupt request t3oe t3out txin input clock interrupt request mcb02038 txi x = (2, 4)
c165h general purpose timer unit data sheet 218 2001-04-19 p r e l i m i n a r y - exc er p t - note: the direction control for t2in and for t4in must be set to 'input', and the level of the capture trigger signal should be held high or low for at least 4 f timer (fm1 = ?1?) cycles before it changes to ensure correct edge detection. 10.1.2 functional description of timer block 2 timer block 2 includes the two timers t5 (referred to as the auxiliary timer) and t6 (referred to as the core timer), and the 16-bit capture/reload register caprel. note: the block 2 timer t5 and timer t6 can be used by software only. there exist no external pin for timer t5 and t6. additional, there is no external pin connected to register caprel, see also figure 57 , page 200. the count direction (up / down) must be programmed via software. an overflow/ underflow of core timer t6 is indicated by the output toggle latch t6otl whose state may be output on line t6ofl. the auxiliary timer t6 may be reloaded with the contents of caprel. the toggle bit also supports the concatenation of t6 with auxiliary timer t5, while concatenation of t6 with other timers is provided through line t6ofl. triggered by an external signal, t3in or t3eud, the contents of timer t5 can be captured into register caprel, and t5 may optionally be cleared. both timer t6 and t5 can count up or down, and the current timer value can be read or modified by the cpu in the non- bitaddressable sfrs t5 and t6.
c165h general purpose timer unit data sheet 219 2001-04-19 p r e l i m i n a r y - exc er pt - figure 71 structure of timer block 2 10.1.2.1 core timer t6 the operation of the core timer t6 is controlled by its bitaddressable control register t6con. timer 6 run bit the timer can be started or stopped by software through bit t6r (timer t6 run bit). setting bit t6r to ?1? will start the timer, clearing t6r stops the timer. count direction control the count direction of the core timer can be controlled by software only. the count direction can be altered by setting or clearing bit t6ud. note: bit t6ude of register t6con must be always set to ?0?. the count direction can be changed regardless of whether the timer is running or not. 2 n : 1 f hw_clk t5 mode control gpt2 timer t5 2 n : 1 f hw_clk t6 mode control gpt2 timer t6 gpt2 caprel t6otl t3in/ t3eud u/d u/d in te rru pt request in te rru pt request in te rru pt request t6ofl clear capture ct3 mcb03999 clear
c165h general purpose timer unit data sheet 220 2001-04-19 p r e l i m i n a r y - exc er p t - note: the direction control works the same for core timer t6 and for auxiliary timer t5. therefore the lines and bits are named tx... timer 6 overflow/underflow monitoring an overflow or underflow of timer t6 will clock the toggle latch t6otl in control register t6con. t6otl can also be set or reset by software. in addition, t6otl can be used in conjunction with the timer over/underflows as an input for the counter function of the auxiliary timer t5. for this purpose, an internal connection is provided for this option. an overflow or underflow of timer t6 can also be used to clock other timers. for this purpose, there is the special output line t6ofl. timer 6 in timer mode timer mode for the core timer t6 is selected by setting bit field t6m in register t6con to ?000 b ?. in this mode, t6 is clocked with the module clock divided by a programmable prescaler, which is selected by bit field t6i. the input frequency f t6 for timer t6 and its resolution r t6 are scaled linearly with lower clock frequencies f timer , as can be seen from the following formula: table 34 core timer t6 count direction control bit txude bit txud count direction 0 0 count up 0 1 count down f t6 = f timer 4 * 2 r t6 [ s] = f timer [mhz] 4 * 2
c165h general purpose timer unit data sheet 221 2001-04-19 p r e l i m i n a r y - exc er pt - figure 72 block diagram of core timer t6 in timer mode 10.1.2.2 auxiliary timer t5 the auxiliary timer t5 can be configured for timer mode with the same options for the timer frequencies and the count signal as the core timer t6. in addition, the auxiliary timer can be concatenated with the core timer. the individual configuration for timer t5 is determined by its bitaddressable control register t5con. note that functions which are present in both timers of timer block 2 are controlled in the same bit positions and in the same manner in each of the specific control registers. run control for auxiliary timer t5 can be handled by the associated run control bit t5r in register t5con. alternatively, a remote control option (t5rc = ?1?) may be enabled to start and stop t5 via the run bit t6r of core timer t6. note: the auxiliary timer has no overflow/underflow toggle latch. therefore, an output line for overflow/underflow monitoring is not provided. count direction control for auxiliary timer the count direction of the auxiliary timer can be controlled in the same way as for the core timer t6. the description and the table apply accordingly. timer t5 in counter mode counter mode for the auxiliary timer t5 is selected by setting bit field t5m in register t5con to ?001 b ?. in counter mode, timer t5 can be clocked by a transition of timer t6?s output signal t6ofl only. core timer tx txotl interrupt request txr 2 n : 1 txl up/ down txude mcb02028 f hw_clk txud x = 6
c165h general purpose timer unit data sheet 222 2001-04-19 p r e l i m i n a r y - exc er p t - figure 73 block diagram of auxiliary timer t5 in counter mode the event causing an increment or decrement of the timer can be a positive, a negative, or both a positive and a negative transition at signal t6ofl (toggle latch t6otl). bit field t5p in control register t5con selects the triggering transition (see table below). note: only state transitions of t6otl which are caused by the overflows/underflows of t6 will trigger the counter function of t5. modifications of t6otl via software will not trigger the counter function of t5. table 35 auxiliary timer (counter mode) input edge selection t5p triggering edge for counter increment / decrement x 0 0 none. counter t5 is disabled 0 0 1 reserved, do not use this combination 0 1 0 reserved, do not use this combination 0 1 1 reserved, do not use this combination 1 0 1 positive transition (rising edge) of output toggle latch t6otl 1 1 0 negative transition (falling edge) of output toggle latch t6otl 1 1 1 any transition (rising or falling edge) of output toggle latch t6otl auxiliary timer tx interrupt request txr up/ down txud txude mcb02221 txl t6ofl edge select x = 5
c165h general purpose timer unit data sheet 223 2001-04-19 p r e l i m i n a r y - exc er pt - 10.1.2.3 timer concatenation using the toggle bit t6otl as a clock source for the auxiliary timer in counter mode concatenates the core timer t6 with the auxiliary timer. depending on which transition of t6otl is selected to clock the auxiliary timer, this concatenation forms a 32-bit or a 33- bit timer / counter. l 32-bit timer/counter: if both a positive and a negative transition of t6otl is used to clock the auxiliary timer, this timer is clocked on every overflow/underflow of the core timer t6. thus, the two timers form a 32-bit timer. l 33-bit timer/counter: if either a positive or a negative transition of t6otl is selected to clock the auxiliary timer, this timer is clocked on every second overflow/underflow of the core timer t6. this configuration forms a 33-bit timer (16-bit core timer+t6otl+16-bit auxiliary timer). the count directions of the two concatenated timers are not required to be the same. this offers a wide variety of different configurations. figure 74 concatenation of core timer t6 and auxiliary timer t5 core timer t6 t6otl interrupt request t6r 2 n : 1 t6l mcb02034gpt2 f hw_clk up/down auxiliary timer t5 t5r t5l edge select t5ir interrupt request *) note: line ?*? only affected by over/underflows of t6, but not by software modifications of t6otl.
c165h general purpose timer unit data sheet 224 2001-04-19 p r e l i m i n a r y - exc er p t - timer block 2 capture/reload register caprel in reload mode the 16-bit capture/reload register caprel can be used as a reload register for the core timer t6. this mode is selected by setting bit t6sr = ?1? in register t6con. the event causing a reload in this mode is an overflow or underflow of the core timer t6. when timer t6 overflows from ffff h to 0000 h (when counting up) or when it underflows from 0000 h to ffff h (when counting down), the value stored in register caprel is loaded into timer t6. this will not set the interrupt request flag crir associated with the caprel register. however, interrupt request flag t6ir will be set indicating the overflow/underflow of t6. figure 75 timer block 2 register caprel in reload mode 10.1.3 gpt register set all gpt12 related registers are summarized in the overview table below. table 36 gpt register overview name description address reset value gptclc gpt clock control register fe4c h 0000 h t2con timer 2 function control register ff40 h 0000 h t3con timer 3 function control register ff42 h 0000 h t4con timer 4 function control register ff44 h 0000 h t5con timer 5 function control register ff46 h 0000 h t6con timer 6 function control register ff48 h 0000 h t2 gpt1 timer 2 register fe40 h 0000 h core timer t6 up/down interrupt request input clock mcb02045 t6otl t6sr caprel register t6ofl
c165h general purpose timer unit data sheet 225 2001-04-19 p r e l i m i n a r y - exc er pt - gpt clock control register gptclc (fe4c h ) reset value: 0000 h t3 gpt1 timer 3 register fe42 h 0000 h t4 gpt1 timer 4 register fe44 h 0000 h t5 gpt2 timer 5 register fe46 h 0000 h t6 gpt2 timer 6 register fe48 h 0000 h caprel capture reload register fe4a h 0000 h t2ic 1) gpt1 timer 2 interrupt control register ff60 h 0000 h t3ic 1) gpt1 timer 3 interrupt control register ff62 h 0000 h t4ic 1) gpt1 timer 4 interrupt control register ff64 h 0000 h t5ic 1) gpt2 timer 5 interrupt control register ff66 h 0000 h t6ic 1) gpt2 timer 6 interrupt control register ff68 h 0000 h cric 1) gpt2 caprel interrupt control register ff6a h 0000 h 1) for the interrupt control register description, please refer to chapter 6.2, page 98. bit function gptdisr gpt disable request bit gptdisr = ? 0 ? : gpt clock disable not requested gptdisr = ? 1 ? : gpt clock disable requested gptdiss gpt disable status bit gptdiss = ? 0 ? : gpt clock enabled gptdiss = ? 1 ? : gpt clock disabled suspen peripheral suspend enable bit for ocds suspen = ? 0 ? : peripheral suspend disabled suspen = ? 1 ? : peripheral suspend enabled exdisr external disable request exrdis = ? 0 ? : external clock disable request is enabled exrdis = ? 1 ? : external clock disable request is disabled table 36 gpt register overview (cont?d) name description address reset value 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 gpt disr gpt diss 0 0 0 0 0 0 rw r rw rw 0 0 0 0 0 0 sus pen ex disr
c165h general purpose timer unit data sheet 226 2001-04-19 p r e l i m i n a r y - exc er p t - function control registers the operating mode of the core timer t3 is configured and controlled via its bitaddressable control register t3con. t3con timer 3 control register reset value: 0000 h 1514131211109876543210 t3 iren t3 rdir t3ch dir t3 edg e fm1 t3 otl t3oe t3 ude t3ud t3r t3m t3i field bits type value description t3i [2:0] rw timer 3 input parameter selection timer mode see table 37 for encoding gated timer see table 37 for encoding counter mode see table 38 for encoding incremental interface mode see table 39 for encoding t3m [5:3] rw 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 timer 3 mode control timer mode counter mode gated timer with gate active low gated timer with gate active high reserved . do not use this combination! reserved . do not use this combination! incremental interface mode ( rotation detection ) incremental interface mode ( edge detection ) t3r 6rw 0 1 timer 3 run bit timer / counter 3 stops timer / counter 3 runs t3ud 7rw 0 1 timer 3 up / down control (when t3ude = ?0) counting ?up? counting ?down? t3ude 8rw 0 1 timer 3 external up/down enable counting direction is internally controlled by sw counting direction is externally controlled by line t3eud
c165h general purpose timer unit data sheet 227 2001-04-19 p r e l i m i n a r y - exc er pt - t3oe 9rw 0 1 overflow/underflow output enable t3 overflow/underflow can not be externally monitored t3 overflow/underflow may be externally monitored via t3out t3otl 10 rw 0 / 1 timer 3 output toggle latch toggles on each overflow / underflow of t3. can be set or reset by software. fm1 11 rw 0 1 fast mode for timer block 1 the maximum input frequency for timer 2/3/4 is f timer / 8. the maximum input frequency for timer 2/3/4 is f timer / 4. t3edge 12 rw 0 1 timer 3 edge detection the bit is set on each successful edge detection. the bit has to be reset by sw. no count edge was detected a count edge was detected t3chdir 13 rw 0 1 timer 3 count direction change the bit is set on a change of the countdirection of timer 3. the bit has to be reset by sw. no change in count direction was detected a change in count direction was detected t3rdir 14 r 0 1 timer 3 rotation direction timer 3 counts up. timer 3 counts down. t3iren 15 rw 0 1 timer 3 interrupt enable interrupt generation for t3chdir and t3edge is disabled. interrupt generation for t3chdir and t3edge is enabled. table 37 timer 3 input parameter selection for timer mode and gated mode t3i prescaler for f timer ( fm1 = 0 ) prescaler for f timer ( fm1 = 1 ) 000 8 4 001 16 8 010 32 16 011 64 32 field bits type value description
c165h general purpose timer unit data sheet 228 2001-04-19 p r e l i m i n a r y - exc er p t - 100 128 64 101 256 128 110 512 256 111 1014 512 table 38 timer 3 input parameter selection for counter mode t3i triggering edge for counter update 000 none. counter t3 is disabled 001 positive transition ( raising edge ) on t3in 010 negative transition ( falling edge ) on t3in 011 any transition ( raising or falling edge ) on t3in 1xx reserved . do not use this combination! table 39 timer 3 input parameter selection for incremental interface mode t3i triggering edge for counter update 000 none. counter t3 stops 001 any transition ( raising or falling edge ) on t3in 010 any transition ( raising or falling edge ) on t3eud 011 any transition ( raising or falling edge ) on t3in or t3eud 1xx reserved . do not use this combination! t2con timer 2 control register reset value: 0000 h 1514131211109876543210 t2 iren t2 rdir t2ch dir t2 edg e 0t2rc t2 ude t2ud t2r t2m t2i table 37 timer 3 input parameter selection for timer mode and gated mode t3i prescaler for f timer ( fm1 = 0 ) prescaler for f timer ( fm1 = 1 )
c165h general purpose timer unit data sheet 229 2001-04-19 p r e l i m i n a r y - exc er pt - field bits type value description t2i [2:0] rw timer 2 input parameter selection timer mode see table 40 for encoding gated timer see table 40 for encoding counter mode see table 41 for encoding incremental interface mode see table 42 for encoding t2m [5:3] rw 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 timer 2 mode control (basic operating mode) timer mode counter mode gated timer with gate active low gated timer with gate active high reload mode capture mode incremental interface mode ( rotation detection) incermental interface mode ( edge detection ) t2r 6rw 0 1 timer 2 run bit timer / counter 2 stops timer / counter 2 runs t2ud 7rw 0 1 timer 2 up / down control (when t2ude = ?0) counting ?up? counting ?down? t2ude 8rw 0 1 timer 2 external up/down enable counting direction is internally controlled by sw counting direction is externally controlled by line t2eud. note: pin p3.5 connected to t2eud is also connected to t4in and to t3eud. t2rc 9rw 0 1 timer 2 remote control timer / counter 2 is controlled by its own run bit t2r timer / counter 2 is controlled by the run bit of core timer 3 0 [11:10] r reserved for future use; reading returns 0; writing to these bit positions has no effect. t2edge 12 rw 0 1 timer 2 edge detection the bit is set on each successful edge detection. the bit has to be reset by sw. no count edge was detected a count edge was detected
c165h general purpose timer unit data sheet 230 2001-04-19 p r e l i m i n a r y - exc er p t - t2chdir 13 rw 0 1 timer 2 count direction change the bit is set on a change of the countdirection of timer 2. the bit has to be reset by sw. no change in count direction was detected a change in count direction was detected t2rdir 14 r 0 1 timer 2 rotation direction timer 2 counts up. timer 2 counts down. t2iren 15 rw 0 1 timer 2 interrupt enable interrupt generation for t2chdir and t2edge is disabled. interrupt generation for t2chdir and t2edge is enabled. table 40 timer 2 input parameter selection for timer mode and gated mode t2i prescaler for f timer ( fm1 = 0 ) prescaler for f timer ( fm1 = 1 ) 000 8 4 001 16 8 010 32 16 011 64 32 100 128 64 101 256 128 110 512 256 111 1014 512 table 41 timer 2 input parameter selection for counter mode t2i triggering edge for counter update x 0 0 none. counter t2 is disabled 0 0 1 positive transition (rising edge) on t2in 0 1 0 negative transition (falling edge) on t2in 0 1 1 any transition (rising or falling edge) on t2in 1 0 1 positive transition (rising edge) of output toggle latch t3otl 1 1 0 negative transition (falling edge) of output toggle latch t3otl 1 1 1 any transition (rising or falling edge) of output toggle latch t3otl field bits type value description
c165h general purpose timer unit data sheet 231 2001-04-19 p r e l i m i n a r y - exc er pt - table 42 timer 2 input parameter selection for incremental interface mode t2i triggering edge for counter update 000 none. counter t2 stops 001 any transition ( raising or falling edge ) on t2in 010 any transition ( raising or falling edge ) on t2eud 011 any transition ( raising or falling edge ) on t2in or t2eud 1xx reserved . do not use this combination! t4con timer 4 control register reset value: 0000 h 1514131211109876543210 t4 iren t4 rdir t4ch dir t4 edg e ?0? t4rc ?0? (t4 ude) t4ud t4r t4m t4i field bits type value description t4i [2:0] rw timer 4 input parameter selection timer mode see table 40 for encoding gated timer see table 40 for encoding counter mode see table 41 for encoding t4m [5:3] rw 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 timer 4 mode control (basic operating mode) timer mode counter mode gated timer with gate active low gated timer with gate active high reload mode capture mode reserved. do not use this combination. reserved. do not use this combination. t4r 6rw 0 1 timer 4 run bit timer / counter 4 stops timer / counter 4 runs t4ud 7rw 0 1 timer 4 up / down control counting ?up? counting ?down? ?0? (t4ude-bit) 8rw 0 timer 4 external up/down enable this bit must be set to ?0? signal.
c165h general purpose timer unit data sheet 232 2001-04-19 p r e l i m i n a r y - exc er p t - t4rc 9rw 0 1 timer 4 remote control timer / counter 4 is controlled by its own run bit t4r timer / counter 4 is controlled by the run bit of core timer 3 ?0? [11:10] r reserved for future use; reading returns 0; writing to these bit positions has no effect. t4edge 12 rw 0 1 timer 4 edge detection the bit is set on each successful edge detection. the bit has to be reset by sw. no count edge was detected a count edge was detected t4chdir 13 rw 0 1 timer 4 count direction change the bit is set on a change of the countdirection of timer 4. the bit has to be reset by sw. no change in count direction was detected a change in count direction was detected t4rdir 14 r 0 1 timer 4 rotation direction timer 4 counts up. timer 4 counts down. t4iren 15 rw 0 1 timer 4 interrupt enable interrupt generation for t4chdir and t4edge is disabled. interrupt generation for t4chdir and t4edge is enabled. table 43 timer 4 input parameter selection for timer mode and gated mode t4i prescaler for f timer ( fm1 = 0 ) prescaler for f timer ( fm1 = 1 ) 000 8 4 001 16 8 010 32 16 011 64 32 100 128 64 101 256 128 110 512 256 111 1014 512 field bits type value description
c165h general purpose timer unit data sheet 233 2001-04-19 p r e l i m i n a r y - exc er pt - table 44 timer 4 input parameter selection for counter mode t4i triggering edge for counter update x 0 0 none. counter t4 is disabled 0 0 1 positive transition (rising edge) on t4in 0 1 0 negative transition (falling edge) on t4in 0 1 1 any transition (rising or falling edge) on t4in 1 0 1 positive transition (rising edge) of output toggle latch t3otl 1 1 0 negative transition (falling edge) of output toggle latch t3otl 1 1 1 any transition (rising or falling edge) of output toggle latch t3otl t6con timer 6 control register reset value: 0000 h 1514131211109876543210 t6sr t6 clr ?0? fm2 t6 otl ?0? (t6 oe) ?0? (t6 ude) t6ud t6r t6m t6i field bits type value description t6i [2:0] rw timer 6 input parameter selection timer mode see table 45 for encoding t6m [5:3] rw 0 0 0 0 0 1 0 1 0 0 1 1 1 x x timer 6 mode control (basic operating mode) timer mode reserved . do not use this combination! reserved . do not use this combination! reserved . do not use this combination! reserved . do not use this combination! t6r 6rw 0 1 timer 6 run bit timer / counter 6 stops timer / counter 6 runs t6ud 7rw 0 1 timer 6 up / down control counting ?up? counting ?down? ?0? (t6ude) 8rw 0 timer 6 external up/down enable this bit must be set to ?0? signal ?0? (t6oe) 9rw 0 overflow/underflow output enable this bit must be set to ?0? signal
c165h general purpose timer unit data sheet 234 2001-04-19 p r e l i m i n a r y - exc er p t - t6otl 10 rw 0 / 1 timer 6 output toggle latch toggles on each overflow / underflow of t6. can be set or reset by software. fm2 11 rw 0 1 fast mode for timer block 2 the maximum input frequency for timer 5/6 is f timer / 4. the maximum input frequency for timer 5/6 is f timer / 2. ?0? [13:12] r reserved for future use; reading returns 0; writing to these bit positions has no effect. t6clr 14 rw 0 1 timer 6 clear bit timer 6 is not cleared on a capture event timer 6 is cleared on a capture event t6sr 15 rw 0 1 timer 6 reload mode enable reload from register caprel disabled reload from register caprel enabled table 45 timer 6 input parameter selection for timer mode and gated mode t6i prescaler for f timer ( fm2 = 0 ) prescaler for f timer ( fm2 = 1 ) 000 4 2 001 8 4 010 16 8 011 32 16 100 64 32 101 128 64 110 256 128 111 512 256 t5con timer 5 control register reset value: 0000 h 1514131211109876543210 t5sc t5 clr ci cc ?1? (ct3) t5rc ?0? (t5 ude) t5ud t5r ?0? t5m t5i field bits type value description
c165h general purpose timer unit data sheet 235 2001-04-19 p r e l i m i n a r y - exc er pt - field bits type value description t5i [2:0] rw timer 5 input parameter selection timer mode see table 46 for encoding counter mode see table 47 for encoding t5m [4:3] rw 0 0 0 1 1 0 1 1 timer 5 mode control (basic operating mode) timer mode counter mode reserved. do not use this configuration reserved. do not use this configuration ?0? 5r reserved for future use; reading returns 0; writing to these bit positions has no effect. t5r 6rw 0 1 timer 5 run bit timer / counter 5 stops timer / counter 5 runs t5ud 7rw 0 1 timer 5 up / down control counting ?up? counting ?down? ?0? (t5ude) 8rw 0 timer 5 external up/down enable this bit must be set to ?0? signal t5rc 9rw 0 1 timer 5 remote control timer / counter x is controlled by its own run bit t5r timer / counter 5 is controlled by the run bit of core timer 6 (t6r) ?1? (ct3) 10 rw 0 timer 3 capture trigger enable this bit must be set to ?1? signal cc 11 rw 0 1 capture correction t5 is just captured t5 is decremented by 1 before being captured ci [13:12] rw 0 0 0 1 1 0 1 1 register caprel capture trigger selection capture disabled any transition on t3in any transition on t3eud any transition on t3in or t3eud t5clr 14 rw 0 1 timer 5 clear bit timer 5 not cleared on a capture timer 5 is cleared on a capture t5sc 15 rw 0 1 timer 5 capture mode enable capture into register caprel disabled capture into register caprel enabled
c165h general purpose timer unit data sheet 236 2001-04-19 p r e l i m i n a r y - exc er p t - table 46 timer 5 input parameter selection for timer mode t5i prescaler for f timer ( fm2 = 0 ) prescaler for f timer ( fm2 = 1 ) 000 4 2 001 8 4 010 16 8 011 32 16 100 64 32 101 128 64 110 256 128 111 512 256 table 47 timer 5 input parameter selection for counter mode t5i triggering edge for counter update x 0 0 none. counter t5 is disabled 0 0 1 reserved , do not use this combination 0 1 0 reserved , do not use this combination 0 1 1 reserved , do not use this combination 1 0 1 positive transition (rising edge) of output toggle latch t6otl 1 1 0 negative transition (falling edge) of output toggle latch t6otl 1 1 1 any transition (rising or falling edge) of output toggle latch t6otl t2/t3/t4/t5/t6 timer tx register reset value: 0000 h 1514131211109876543210 value field bits type value description value [15:0] rw timer tx register 16 bit register contains the actual timer value of the respective timer tx.
c165h general purpose timer unit data sheet 237 2001-04-19 p r e l i m i n a r y - exc er pt - caprel gpt2 caprel register reset value: 0000 h 1514131211109876543210 value field bits type value description value [15:0] rw gpt2 caprel register 16 bit register contains the actual value of the caprel register.
c165h asynchronous/synchr. serial interface data sheet 238 2001-04-19 p r e l i m i n a r y - exc er p t - 11 asynchronous/synchr. serial interface the asynchronous/synchronous serial interface (asc) provides serial communication between the c165h and other microcontrollers, microprocessors or external peripherals. the asc supports a certain protocol to transfer data via a serial interconnection. 11.1 functional description the asc supports full-duplex asynchronous communication up to 2.25 mbaud and half- duplex synchronous communication up to 4.5 mbaud (@ 36 mhz cpu clock which is equal to the asc module clock). in synchronous mode, data are transmitted or received synchronous to a shift clock which is generated by the microcontroller. in asynchronous mode, 8- or 9-bit data transfer, parity generation, and the number of stop bits can be selected. 11.1.1 features  full duplex asynchronous operating modes ? 8- or 9-bit data frames, lsb first ? parity bit generation/checking ? one or two stop bits ? baudrate from 2.25 mbaud to 0.5364 baud (@ 36 mhz module clock = cpu clock) ? multiprocessor mode for automatic address/data byte detection ? loop-back capability ? support for irda data transmission/reception up to max. 115.2 kbaud  autobaud detection unit for asynchronous operating modes ? detection of standard baudrates 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400 baud ? detection of non-standard baudrates ? detection of asynchronous modes 7 bit, even parity; 7 bit, odd parity; 8 bit, even parity; 8 bit, odd parity; 8 bit, no parity ? automatic initialization of control bits and baudrate generator after detection ? detection of a serial two-byte ascii character frame  recently introduced fractional divider ? the fractional divider drastically improves the accuracy of the adjustment for baudrates ? standard baud rates generation with very small deviation (230.4 kbaud < 0.01%, 460.8 kbaud < 0.15 %, 691.2 kbaud < 0.04 %, 921.6 kbaud < 0.15 % ) @ 36 mhz
c165h asynchronous/synchr. serial interface data sheet 239 2001-04-19 p r e l i m i n a r y - exc er pt -  half-duplex 8-bit synchronous operating mode ? baudrate from 4.5 mbaud to 366.21 baud (@ 36 mhz module clock = cpu clock)  double buffered transmitter/receiver  interrupt generation ? on a transmitter buffer empty condition ? on a transmit last bit of a frame condition ? on a receiver buffer full condition ? on an error condition (frame, parity, overrun error) ? on the start and the end of a autobaud detection
c165h asynchronous/synchr. serial interface data sheet 240 2001-04-19 p r e l i m i n a r y - exc er p t - 11.1.2 overview figure 76 shows a block diagram of the asc with its operating modes (asynchronous and synchronous modes.). figure 76 block diagram of the asc f mod baudrate timer serial port control receive / transmit buffers and shift registers rxdo txd synchronous mode shift clock f mod baudrate timer serial port control receive / transmit buffers and shift registers irda coding mux irda decoding mux rxd txd prescaler / fractional divider asynchronous mode f div autobaud detection 2 or 3 rxdi note: rxdi and rxdo are concatenated in the port logic to pin rxd.
c165h asynchronous/synchr. serial interface data sheet 241 2001-04-19 p r e l i m i n a r y - exc er pt - 11.1.3 register description the asc registers can be basically divided into four types of registers as shown in figure 77 . figure 77 sfrs associated with asc table 48 asc register summary name address reset value type 1) description s0clc ffba h 0000 h rw / r asc clock control register s0con ffb0 h 0000 h rwh control register abs0con fef8 h 0000 h rwh autobaud control register abstat fefe h 0000 h rwh autobaud status register s0bg feb4 h 0000 h rw baudrate timer reload register s0fdv feb6 h 0000 h rw fractional divider register s0pmw feaa h 0000 h rw irda pulse mode and width register s0tbuf feb0 h 0000 h rw transmit buffer register s0rbuf feb2 h 0000 h r receive buffer register s0clc clock control register s0id identification register s0con control register abs0conautobaud control register abstat autobaud status register s0tic asc transmit interrupt control register s0ric asc receive interrupt control register s0bg baudrate timer reload register s0fdv fractional divider register s0pmw irda pulse mode and width register s0tbuf transmit buffer register s0rbuf receive buffer register (read only) s0eic asc error interrupt control register s0tbic asc transmit buffer interrupt control register data registers control register s0con s0tbuf s0rbuf s0bg s0fdv s0pmw s0clc system registers abs0con abstat interrupt control s0tic s0ric s0eic s0tbic
c165h asynchronous/synchr. serial interface data sheet 242 2001-04-19 p r e l i m i n a r y - exc er p t - asc clock control register s0clc (ffba h ) reset value: 0000 h the serial operating modes of the asc module are controlled by its control register s0con. this register contains control bits for mode and error check selection, and status flags for error identification. s0tic ff6c h 0000 h rw serial channel 0 transmit interrupt control register s0ric ff6e h 0000 h rw serial channel 0 receive interrupt control register s0eic ff70 h 0000 h rw serial channel 0 error interrupt control register s0tbic f19c h 0000 h rw serial channel 0 transmit buffer ic register 1) r: read only; w: write only; rw: read- and writeable; rwh: like rw, but sfr/bit is also affected by hardware. bit function s0disr asc disable request bit s0disr = ? 0 ? : asc clock disable not requested s0disr = ? 1 ? : asc clock disable requested s0diss asc disable status bit s0diss = ? 0 ? : asc clock enabled s0diss = ? 1 ? : asc clock disabled suspen peripheral suspend enable bit for ocds suspen = ? 0 ? : peripheral suspend disabled suspen = ? 1 ? : peripheral suspend enabled exdisr external disable request exrdis = ? 0 ? : external clock disable request is enabled exrdis = ? 1 ? : external clock disable request is disabled table 48 asc register summary (cont?d) name address reset value type 1) description 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 s0 disr s0 diss 0 0 0 0 0 0 rw r rw rw 0 0 0 0 0 0 sus pen ex disr
c165h asynchronous/synchr. serial interface data sheet 243 2001-04-19 p r e l i m i n a r y - exc er pt - s0con control register 1514131211109876543210 r lb brs odd fde oe fe pe oen fen pen/ rxdi ren stp m field bits type value description m 2-0 rwh 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 mode selection 8-bit data synchronous operation 8-bit data async. operation irda mode, 8-bit data async. operation 7-bit data + parity async. operation 9-bit data async. operation 8-bit data + wake up bit async. operation reserved. do not use this combination! 8-bit data + parity async. operation bits are set/cleared by hardware after a successfull autobaud detection operation. note: in synchronous operation (m=?000?), the fractional divider is always disabled. stp 3rw 0 1 number of stop bit selection one stop bit two stop bits ren 4rwh 0 1 receiver enable control receiver diabled receiver enabled bit can be affected during autobaud detection operation when bit aben_auren is set. bit is reset by hardware after reception of byte in synchronous mode. pen rxdi 5rw 0 1 0 1 parity check enable / irda input inverter enable all asynchronous modes without irda mode: ignore parity check parity only in irda mode (m=010): rxd input is not inverted rxd input is inverted fen 6rw 0 1 framing check enable (async. modes only) ignore framing errors check framing errors
c165h asynchronous/synchr. serial interface data sheet 244 2001-04-19 p r e l i m i n a r y - exc er p t - note: serial data transmission or reception is only possible when the run bit s0con.r is set to ?1?. otherwise the serial interface is idle. do not program the mode control field s0con.m to one of the reserved combinations to avoid unpredictable behaviour of the serial interface. oen 7rw 0 1 overrun check enable ignore overrun errors check overrun errors pe 8rwh parity error flag set by hardware on a parity error (pen=?1?). must be reset by software. fe 9rwh framing error flag set by hardware on a framing error (fen=?1?). must be reset by software. oe 10 rwh overrun error flag set by hardware on an overrun error (oen=?1?). must be reset by software. fde 11 rw 0 1 fractional divider enable fractional divider disabled fractional divider is enabled and used as prescaler for baudrate timer (bit brs is don?t care) odd 12 rwh 0 1 parity selection even parity selected (parity bit set on odd number of ?1?s in data) odd parity selected (parity bit set on even number of ?1?s in data) bit is be set/cleared by hardware after a successfull autobaud detection operation. brs 13 rw 0 1 baudrate selection baudrate timer prescaler divide-by-2 selected baudrate timer prescaler divide-by-3 selected brs is don?t care if fde=1 (fractional divider enabled) lb 14 rw 0 1 loopback mode enable loopback mode disabled loopback mode enabled r 15 rw 0 1 baudrate generator run control baudrate generator disabled ( asc_p inactive) baudrate generator enabled bg should only be written if r=?0?. field bits type value description
c165h asynchronous/synchr. serial interface data sheet 245 2001-04-19 p r e l i m i n a r y - exc er pt - the autobaud control register abs0con of the asc module is used to control the autobaud detection operation. it contains its general enable bit, the interrupt enable control bits, and data path control bits. abs0con autobaud control register 1514131211109876543210 0000 rx inv tx inv abem 000 fc det en ab det en abst en aur en ab en field bits type value description aben 0rwh 0 1 autobaud detection enable autobaud detection is disabled autobaud detection is enabled aben is reset by hardware after a successful autobaud detection; (with the stop bit detection of the second character). resetting aben by software if it was set aborts the autobaud detection. auren 1rw 0 1 automatic autobaud control of con_ren con_ren is not affected during autobaud detection con_ren is cleared (receiver disabled) when aben and auren are set together. con_ren is set (receiver enabled) after a successful autobaud detection (with the stop bit detection of the second character). absten 2rw 0 1 start of autobaud detection interrupt enable start of autobaud detection interrupt disabled start of autobaud detection interrupt enabled abdeten 3rw 0 1 autobaud detection interrupt enable autobaud detection interrupt disabled autobaud detection interrupt enabled fcdeten 4rw 0 1 first character of two-byte frame detected enable autobaud detection interrupt abdetir becomes active after the two-byte frame recognition autobaud detection interrupt abdetir becomes active after detection of the first and second byte of the two-byte frame.
c165h asynchronous/synchr. serial interface data sheet 246 2001-04-19 p r e l i m i n a r y - exc er p t - the autobaud status register abstat of the asc module indicates the status of the autobaud detection operation. abem 8-9 rw 0 0 0 1 1 0 1 1 autobaud echo mode enable in echo mode the serial data at rxd is switched to txd output. echo mode disabled echo mode is enabled during autobaud detection echo mode is always enabled reserved; txinv 10 rw 0 1 transmit inverter enable transmit inverter disabled transmit inverter enabled rxinv 11 rw 0 1 receive inverter enable receive inverter disabled receive inverter enabled ? 7-5, 15-12 0allreserved abstat autobaud status register 1514131211109876543210 00000000000 det wait scc det scs det fcc det fcs det field bits type value description fcsdet 0rwh 0 1 first character with small letter detected no small ?a? character detected small ?a? character detected bit is cleared by hardware when abcon_aben is set or if fccdet or scsdet or sccdet is set. bit can be also cleared by software. fccdet 1rwh 0 1 first character with capital letter detected no capital ?a? character detected capital ?a? character detected bit is cleared by hardware when abcon_aben is set or if fcsdet or scsdet or sccdet is set. bit can be also cleared by software. field bits type value description
c165h asynchronous/synchr. serial interface data sheet 247 2001-04-19 p r e l i m i n a r y - exc er pt - note: scsdet or sccdet are set when the second character has been recognized. con_aben is reset and abdetir set after scsdet or sccdet have seen set. scsdet 2rwh 0 1 second character with small letter detected no small ?t? character detected small ?t? character detected bit is cleared by hardware when abcon_aben is set or if fcsdet or fccdet or sccdet is set. bit can be also cleared by software. sccdet 3rwh 0 1 second character with capital letter detected no capital ?t? character detected capital ?t? character detected bit is cleared by hardware when abcon_aben is set or if fcsdet or fccdet or scsdet is set. bit can be also cleared by software. detwait 4rwh 0 1 autobaud detection is waiting either character ?a?, ?a?, ?t?, or ?t? has been detected. the autobaud detection unit waits for the first ?a? or ?a? bit is cleared when either fcsdet or fccdet is set (?a? or ?a? detected). bit can be also cleared by software. detwait is set by hardware when abcon_aben is set. ? 15-5 0 all reserved field bits type value description
c165h asynchronous/synchr. serial interface data sheet 248 2001-04-19 p r e l i m i n a r y - exc er p t - the baudrate timer reload register s0bg of the asc module contains the 13-bit reload value for the baudrate timer in asynchronous and sychronous mode. the fractional divider register s0fdv of the asc module contains the 9-bit divider value for the fractional divider (asynchronous mode only). it is also used for reference clock generation of the autobaud detection unit. s0bg baudrate timer/reload register 1514131211109876543210 0 0 0 br_value field bits type value description br_value 12-0 rw all baudrate timer/reload register value reading bg returns the 13-bit content of the baudrate timer (bits 15....13 return 0); writing bg loads the baudrate timer reload register (bits 15....13 are don?t care). bg should only be written if con_r=?0?. ? 15-13 0 all reserved s0fdv fractional divider register 1514131211109876543210 0000000 fd_value field bits type value description fd_value 8-0 rw all fractional divider register value fdv contains the 9-bit value n of the fractional divider which defines the fractional divider ratio: n/512 n=0-511). with n=0, the fractional divider is switched off (input=output frequency, f div = f mod , see figure 86 ). ? 15-9 0 all reserved
c165h asynchronous/synchr. serial interface data sheet 249 2001-04-19 p r e l i m i n a r y - exc er pt - the irda pulse mode and width register s0pmw of the asc module contains the 8-bit irda pulse width value and the irda pulse width mode select bit. this register is only required in the irda operating mode. s0pmw irda pulse mode/width register 1514131211109876543210 0000000irpw pw_value field bits type value description pw_value 7-0 rw all irda pulse width value pw_value is the 8-bit value n, which defines the variable pulse width of an irda pulse. depending on the asc_p input frequency f mod , this value can be used to adjust the irda pulse width to value which is not equal 3/16 bit time (e.g. 1.6 s). irpw 8rw 0 1 irda pulse width mode control irda pulse width is 3/16 of the bit time irda pulse width is defined by pw_value ? 15-9 0 all reserved
c165h asynchronous/synchr. serial interface data sheet 250 2001-04-19 p r e l i m i n a r y - exc er p t - the transmitter buffer register s0tbuf of the asc module contains the transmit data value in asynchronous and synchronous modes. s0tbuf transmitter buffer register 1514131211109876543210 0000000 td_value field bits type value description td_value 8-0 rw all transmit data register value tbuf contains the data to be transmitted in asynchronous and synchronous operating mode of the asc. data transmission is double buffered, therefore, a new value can be written to tbuf before the transmission of the previous value is complete. ? 15-9 0 all reserved
c165h asynchronous/synchr. serial interface data sheet 251 2001-04-19 p r e l i m i n a r y - exc er pt - the receiver buffer register s0rbuf of the asc module contains the receive data value in asynchronous and synchronous modes. s0tic sfr reset value: - - 00 h s0ric sfr reset value: - - 00 h s0eic sfr reset value: - - 00 h s0rbuf receive buffer register 1514131211109876543210 0000000 rd_value field bits type value description rd_value 8-0 rw all receive data register value s0rbuf contains the reveived data bits and, depending on the selected mode, the parity bit in asynchronous and synchronous operating mode of the asc. in asynchronous operating mode with m=011 (7- bit data + parity) the received parity bit is written into rd7. in asynchronous operating mode with m=111 (8- bit data + parity) the received parity bit is written into rd8. ? 15-9 0 all reserved s0 tie s0 tir 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw - - - - rw rw - - - - glvl ilvl s0 rie s0 rir 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw - - - - rw rw - - - - glvl ilvl s0 eir s0 eie 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw - - - - rw rw - - - - glvl ilvl
c165h asynchronous/synchr. serial interface data sheet 252 2001-04-19 p r e l i m i n a r y - exc er p t - s0tbic sfr reset value: - - 00 h note: please refer to the general interrupt control register description on page 99 for an explanation of the control fields. 11.1.4 general operation the asc supports full-duplex asynchronous communication up to 2.25 mbaud and half- duplex synchronous communication up to 4.5 mbaud (@ 36 mhz cpu clock which is equal to the asc module clock). in synchronous mode, data are transmitted or received synchronous to a shift clock which is generated by the microcontroller. in asynchronous mode, 8- or 9-bit data transfer, parity generation, and the number of stop bits can be selected. parity, framing, and overrun error detection is provided to increase the reliability of data transfers. transmission and reception of data is double-buffered. for multiprocessor communication, a mechanism to distinguish address from data bytes is included. testing is supported by a loop-back option. a 13-bit baudrate timer with a versatile input clock divider circuitry provides the asc with the serial clock signal. in a special asynchronous mode, the asc supports irda data transmission up to 115.2 kbaud with fixed or programmable irda pulse width. a autobaud detection unit allows to detect asynchronous data frames with its baudrate and mode with automatic initialization of the baudrate generator and the mode controll bits. a transmission is started by writing to the transmit buffer register s0tbuf. only the number of data bits which is determined by the selected operating mode will actually be transmitted, ie. bits written to positions 9 through 15 of register s0tbuf are always insignificant. data transmission is double-buffered, so a new character may be written to the transmit buffer register, before the transmission of the previous character is complete. this allows the transmission of characters back-to-back without gaps. data reception is enabled by the receiver enable bit con_ren. after reception of a character has been completed, the received data and, if provided by the selected operating mode, the received parity bit can be read from the (read-only) receive buffer register s0rbuf. bits in the upper half of s0rbuf which are not valid in the selected operating mode will be read as zeros. data reception is double-buffered, so that reception of a second character may already begin before the previously received character has been read out of the receive buffer register. in all modes, receive buffer overrun error detection can be selected through bit con_oen. when enabled, the overrun error status flag con_oe and the error interrupt request line eir will be acitvated when the receive buffer register has not been read by s0 eir s0 eie 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw - - - - rw rw - - - - glvl ilvl
c165h asynchronous/synchr. serial interface data sheet 253 2001-04-19 p r e l i m i n a r y - exc er pt - the time reception of a second character is complete. the previously received character in the receive buffer is overwritten. the loop-back option (selected by bit con_lb) allows the data currently being transmitted to be received simultaneously in the receive buffer. this may be used to test serial communication routines at an early stage without having to provide an external network. in loop-back mode the alternate input/output function of port pins is not required. note: serial data transmission or reception is only possible when the baudrate generator run bit con_r is set to ?1?. otherwise the serial interface is idle. do not program the mode control field com_m to one of the reserved combinations to avoid unpredictable behaviour of the serial interface 11.1.5 asynchronous operation asynchronous mode supports full-duplex communication, where both transmitter and receiver use the same data frame format and the same baudrate. data is transmitted on pin p3.10/txd and received on pin p3.11/rxd. irda data transmission/reception is supported up to 115.2 kbit/s. figure 78 shows the block diagram of the asc when operating in asynchronous mode.
c165h asynchronous/synchr. serial interface data sheet 254 2001-04-19 p r e l i m i n a r y - exc er p t - figure 78 asynchronous mode of serial channel asc 16 2 f mod r 13-bit reload register 13-bit baudrate timer fractional divider mux fde brs serial port control shift clock mstp fe oe pe ren fen pen oen lb receive int. request transmit int. request transmit buffer int. request error int. request transmit buffer reg. tbuf receive shift register transmit shift register irda coding txd internal bus samp- ling mux rxd irda decoding f div f brt shift clock f br receive buffer reg. rbuf mux rir tir tbir eir autobaud detection odd 3 abstiri abdet ir autobaud start int. autobaud detect int. 1 1 mux mux
c165h asynchronous/synchr. serial interface data sheet 255 2001-04-19 p r e l i m i n a r y - exc er pt - 11.1.5.1 asynchronous data frames 8-bit data frames 8-bit data frames either consist of 8 data bits d7...d0 (con_m=?001 b ?), or of 7 data bits d6...d0 plus an automatically generated parity bit (con_m=?011 b ?). parity may be odd or even, depending on bit con_odd. an even parity bit will be set, if the modulo-2-sum of the 7 data bits is ?1?. an odd parity bit will be cleared in this case. parity checking is enabled via bit con_pen (always off in 8-bit data mode). the parity error flag con_pe will be set along with the error interrupt request flag, if a wrong parity bit is received. the parity bit itself will be stored in bit rbuf.7. figure 79 asynchronous 8-bit frames 9-bit data frames 9-bit data frames either consist of 9 data bits d8...d0 (con_m=?100 b ?), of 8 data bits d7...d0 plus an automatically generated parity bit (con_m=?111 b ?) or of 8 data bits d7...d0 plus wake-up bit (con_m=?101 b ?). parity may be odd or even, depending on bit con_odd. an even parity bit will be set, if the modulo-2-sum of the 8 data bits is ?1?. an odd parity bit will be cleared in this case. parity checking is enabled via bit con_pen (always off in 9-bit data and wake-up mode). the parity error flag con_pe will be set along with the error interrupt request flag, if a wrong parity bit is received. the parity bit itself will be stored in bit rbuf.8. d7 parit d0 lsb d1 d2 d3 d4 d5 d6 d6 start bit 8 data bits 10-/11-bit uart frame (1st) stop bit 0 1 1 (2nd) stop bit con_m=001 b d0 lsb d1 d2 d3 d4 d5 start bit 7 data bits 10-/11-bit uart frame (1st) stop bit 0 1 1 (2nd) stop bit con_m=011 b
c165h asynchronous/synchr. serial interface data sheet 256 2001-04-19 p r e l i m i n a r y - exc er p t - figure 80 asynchronous 9-bit frames in wake-up mode received frames are only transferred to the receive buffer register, if the 9th bit (the wake-up bit) is ?1?. if this bit is ?0?, no receive interrupt request will be activated and no data will be transferred. this feature may be used to control communication in multi-processor system: when the master processor wants to transmit a block of data to one of several slaves, it first sends out an address byte which identifies the target slave. an address byte differs from a data byte in that the additional 9th bit is a '1' for an address byte and a '0' for a data byte, so no slave will be interrupted by a data 'byte'. an address 'byte' will interrupt all slaves (operating in 8-bit data + wake-up bit mode), so each slave can examine the 8 lsbs of the received character (the address). the addressed slave will switch to 9-bit data mode (eg. by clearing bit con_m.0), which enables it to also receive the data bytes that will be coming (having the wake-up bit cleared). the slaves that were not being addressed remain in 8-bit data + wake-up bit mode, ignoring the following data bytes irda frames the modulation schemes of irda is based on standard asynchronous data transmission frames. the asynchronous data format in irda mode (con_m=010 b ) is defined as follows : 1 start bit / 8 data bits / 1 stop bit the coding/decoding of/to the asynchronous data frames is shown in figure 81 . in general, during the irda transmissions uart frames are encoded into ir frames and vice cersa. a low level on the ir frame indicates a ?led off? state. a high level on the ir frame indicates a ?led on? state. for a ?0? bit in the uart frame a high pulse is generated. for a ?1? bit in the uart frame no pulse is generated. the high pulse starts in the middle of a bit cell and has a fixed width of 3/16 of the bit time. the asc also allows to program the length of the irda high bit 9 d7 d0 lsb d1 d2 d3 d4 d5 d6 start bit 9 data bits 11-/12-bit uart frame (1st) stop bit 0 1 1 (2nd) stop bit con_m=100 b : bit 9 = data bit d8 con_m=101 b : bit 9 = wake-up bit con_m=111 b : bit 9 = parity bit
c165h asynchronous/synchr. serial interface data sheet 257 2001-04-19 p r e l i m i n a r y - exc er pt - pulse. further, the polarity of the received irda pulse cane be inverted in irad mode. figure 81 shows the non-inverted irda pulse scheme. figure 81 irda frame encoding/decoding 11.1.5.2 asynchronous transmission asynchronous transmission begins at the next overflow of the divide-by-16 baudrate timer (transition of the baudrate clock f br ), if bit s0con.r is set and data has been loaded into s0tbuf. the transmitted data frame consists of three basic elements: ? the start bit ? the data field (8 or 9 bits, lsb first, including a parity bit, if selected) ? the delimiter (1 or 2 stop bits) data transmission is double buffered. when the transmitter is idle, the transmit data loaded into register s0tbuf is immediately moved to the transmit shift register thus freeing s0tbuf for the next data to be sent. this is indicated by the transmit buffer interrupt request line tbir being activated. s0tbuf may now be loaded with the next data, while transmission of the previous one is still going on. the transmit interrupt request line tir will be activated before the last bit of a frame is transmitted, ie. before the first or the second stop bit is shifted out of the transmit shift register. the transmitter output pin p3.10/txd must be configured for alternate data output?. 11.1.5.3 asynchronous reception asynchronous reception is initiated by a falling edge (1-to-0 transition) on pin p3.11/ rxd, provided that bits con_r and con_ren are set. the receive data input pin start bit start bit 8 data bits uart frame stop bit bit time 8 data bits ir frame stop bit 010 00 0 1111 010 00 0 1111 pulse width = 3/16 bit time (or variable length) 1/2 bit time
c165h asynchronous/synchr. serial interface data sheet 258 2001-04-19 p r e l i m i n a r y - exc er p t - p3.11/rxd is sampled at 16 times the rate of the selected baudrate. a majority decision of the 7th, 8th and 9th sample determines the effective bit value. this avoids erroneous results that may be caused by noise. if the detected value is not a '0' when the start bit is sampled, the receive circuit is reset and waits for the next 1-to-0 transition at pin p3.11/rxd. if the start bit proves valid, the receive circuit continues sampling and shifts the incoming data frame into the receive shift register. when the last stop bit has been received, the content of the receive shift register is transferred to the receive data buffer register s0rbuf. simultaneously, the receive interrupt request line rir is activated after the 9th sample in the last stop bit time slot (as programmed), regardless whether valid stop bits have been received or not. the receive circuit then waits for the next start bit (1-to-0 transition) at the receive data input pin. the receiver input pin p3.11/rxd must be configured for input. asynchronous reception is stopped by clearing bit con_ren. a currently received frame is completed including the generation of the receive interrupt request and an error interrupt request, if appropriate. start bits that follow this frame will not be recognized. note: in wake-up mode received frames are only transferred to the receive buffer register, if the 9th bit (the wake-up bit) is ?1?. if this bit is ?0?, no receive interrupt request will be activated and no data will be transferred. 11.1.5.4 irda mode the duration of the irda pulse is normally 3/16 of a bit period. the irda standard also allows the pulse duration being independent of the baudrate or bit period. in this case the transmitted pulse has always the width corresponding to the 3/16 pulse width at 115.2 kbaud which is 1.627 s. both, bit period dependend or fixed irda pulse width generation can be selected. the irda pulse width mode is selected by bit pmw_irpw. in case of fixed irda pulse width generation, the lower 8 bits in register pmw are used to adapt the irda pulse width to a fixed value of e.g. 1.627 s. the fixed irda pulse width is generated by a programmable timer as shown in figure 82 . figure 82 fixed irda pulse generation pmw 8-bit timer f mod start timer irda pulse t ipw
c165h asynchronous/synchr. serial interface data sheet 259 2001-04-19 p r e l i m i n a r y - exc er pt - the irda pulse width can be calculated according the formulas given in table 49 . the name pmw in the formulas of table 49 represents the content of the reload register pmw (pw_value), taken as unsigned 8-bit integer. the content of pmw further defines the minimum irda pulse width (t ipw min ) which is still recognized during a receive operation as a valid irda pulse. this function is independent of the selected irda pulse width mode (fixed or variable) which is defined by bit pmw_irpw. the minimum irda pulse width is calculated by a shift right operation of pmw bit 7-0 by one bit divided by the module clock f mod . note: if pmw_irpw=0 (fixed irda pulse width), pw_value must be a value which assures that t ipw > t ipw min . table 50 gives two examples for typical frequencies of the c165h: 36 mhz and 24 mhz.. 11.1.5.5 rxd/txd data path selection in asynchronous modes the data paths for the serial input and output data of the asc in asynchronous modes are affected by several control bits in the registers con and abcon as shown in figure 83 . the synchronous mode operation is not affected by these data path selection capabilities. the input signal from rxd passes an inverter which is controlled by bit abcon_rxinv. the output signal of this inverter is used for the autobaud detection and may bypass the asc logic in the echo mode (controlled by bit abcon_abem). further, two multiplexers are in the rxd input signal path for providing the loopback mode capability (controlled by bit con_lb) and the irda receive pulse inversion capability (controlled by bit con_rxdi). table 49 formulas for the irda pulse width calculation pmw pmw_irpw formulas 1 ... 255 0 1 table 50 irda pulse width adaption to 1.627 s f mod pmw t ipw error t ipw min 24 mhz 39 1.625 s - 0.12 % 0.79 s 36 mhz 59 1.639 s + 0.74 % 0.81 s t ipw = 16 x baudrate 3 t ipw min = f mod (pmw >> 1) t ipw = f mod pmw
c165h asynchronous/synchr. serial interface data sheet 260 2001-04-19 p r e l i m i n a r y - exc er p t - depending on the asynchronous operating mode (controlled by bitfield con_m), the asc output signal or the rxd input signal in echo mode (controlled by bit abcon_abem) is switched to the txd output via an inverter (controlled by bit abcon_txinv). figure 83 rxd/txd data path in asynchronous modes (asc) note: in echo mode the transmit output signal of the asc logic is blocked by the echo mode output multiplexer. figure 83 also shows that it is not possible to use an irda coded receiver input signal for autobaud detection. 11.1.6 synchronous operation synchronous mode supports half-duplex communication, basically for simple i/o expansion via shift registers. data is transmitted and received via pin rxd while pin txd outputs the shift clock. these signals are alternate functions of port pins p3.11 and p3.10. synchronous mode is selected with con_m=?000 b ?. eight data bits are transmitted or received synchronous to a shift clock generated by the internal baudrate generator. the shift clock is only active as long as data bits are transmitted or received. note: the lines rxdi and rxdo are concatenated in the port logic to pin rxd. rxinv detection autobaud asynch. mode logic asc txd rxd abcon con txinv abem irda coding irda decode mux m mux rxdi mux mux mux lb mux
c165h asynchronous/synchr. serial interface data sheet 261 2001-04-19 p r e l i m i n a r y - exc er pt - figure 84 synchronous mode of serial channel asc_p 11.1.6.1 synchronous transmission synchronous transmission begins within 4 state times after data has been loaded into s0tbuf provided that con_r is set and con_ren=?0? (half-duplex, no reception). exception : in loopback mode (bit con_lb set), con_ren must be set for reception of the transmitted byte. data transmission is double buffered. when the transmitter is idle, the transmit data loaded into s0tbuf is immediately moved to the transmit shift register thus freeing s0tbuf for the next data to be sent. this is indicated by the transmit buffer interrupt request line tbir being activated. s0tbuf may now be loaded with the next data, while transmission of the previous one is still going on. the data bits are transmitted synchronous with the shift clock. after the bit time for the 8th data bit, both txd 4 f mod r 13-bit reload register 13-bit baudrate timer serial port control shift clock m=000 b oe ren oen lb transmit buffer reg. tbuf transmit shift register internal bus mux rxdi f div f brt shift clock f br 0 1 2 3 mux brs receive buffer reg. rbuf receive shift register receive int. request transmit int. request transmit buffer int. request error int. request rir tir tbir eir note: rxdi and rxdo are port logic to pin rxd. rxdo concatenated in the
c165h asynchronous/synchr. serial interface data sheet 262 2001-04-19 p r e l i m i n a r y - exc er p t - txd and rxd will go high, the transmit interrupt request line tir is activated, and serial data transmission stops. pin p3.10/txd must be configured for alternate data output in order to provide the shift clock. pin p3.11/rxd must also be configured for output during transmission. 11.1.6.2 synchronous reception synchronous reception is initiated by setting bit con_ren=?1?. if bit con_r=1, the data applied at rxd is clocked into the receive shift register synchronous to the clock which is output at pin txd. after the 8th bit has been shifted in, the content of the receive shift register is transferred to the receive data buffer rbuf, the receive interrupt request line rir is activated, the receiver enable bit con_ren is reset, and serial data reception stops. pin p3.10/txd must be configured for alternate data output in order to provide the shift clock. pin p3.11/rxd must be configured as alternate data input. synchronous reception is stopped by clearing bit con_ren. a currently received byte is completed including the generation of the receive interrupt request and an error interrupt request, if appropriate. writing to the transmit buffer register while a reception is in progress has no effect on reception and will not start a transmission. if a previously received byte has not been read out of the receive buffer register at the time the reception of the next byte is complete, both the error interrupt request line eir and the overrun error status flag con_oe will be activated/set, provided the overrun check has been enabled by bit con_oen. 11.1.6.3 synchronous timing figure 85 shows timing diagrams of the asc synchronous mode data reception and data transmission. in idle state the shift clock is at high level. with the beginning of a synchronous transmission of a data byte the data is shifted out at rxd with the falling edge of the shift clock. if a data byte is received through rxd data is latched with the rising edge of the shift clock. between two consecutive receive or transmit data bytes one shift clock cycle (f br ) delay is inserted.
c165h asynchronous/synchr. serial interface data sheet 263 2001-04-19 p r e l i m i n a r y - exc er pt - figure 85 asc_p3 synchronous mode waveforms 11.1.7 baudrate generation the serial channel asc has its own dedicated 13-bit baudrate generator with 13-bit reload capability, allowing baudrate generation independent of the gpt timers. the baudrate generator is clocked with a clock (f div ) which is derived via a prescaler from the asc input clock f mod , e.g. 36 mhz. the baudrate timer is counting downwards and can be started or stopped through the baudrate generator run bit con_r. each underflow of the timer provides one clock pulse to the serial channel. the timer is reloaded with the value stored in its 13-bit reload register each time it underflows. the resulting clock f brt is again divided by a factor for the baudrate clock ( 16 in asynchronous modes and 4 in synchronous mode). the prescaler is selected by the bits con_brs and con_fde. in the asynchronous operating modes, additionally to the two fixed dividers a fractional divider prescaler unit is available which allows to select prescaler divider ratios of n/512 with n=0-511. therefore, the baudrate of asc is shift latch shift latch valid shift valid data n+2 shift clock transmit data shift clock transmit data receive data valid data n receive/transmit timing continuous transmit timing data bit n data bit n+1 data bit n+2 d0 d1 d2 d3 d4 d5 d6 d7 d0 d1 d2 d3 1. byte 2. byte receive data d0 d0 d1 d2 d3 d6 d7 d1 d2 d3 d4 d5 data n+1 1. byte 2. byte
c165h asynchronous/synchr. serial interface data sheet 264 2001-04-19 p r e l i m i n a r y - exc er p t - determined by the module clock, the content of s0fdv, the reload value of s0bg and the operating mode (asynchronous or synchronous). register s0bg is the dual-function baudrate generator/reload register. reading bg returns the content of the timer br_value (bits 15...13 return zero), while writing to s0bg always updates the reload register (bits 15...13 are insiginificant). an auto-reload of the timer with the content of the reload register is performed each time con_bg is written to. however, if con_r=?0? at the time the write operation to bg is performed, the timer will not be reloaded until the first instruction cycle after con_r=?1?. for a clean baudrate initialization s0bg should only be written if con_r=?0?. if s0bg is written with con_r=?1?, an unpredicted behaviour of the asc may occur during running transmit or receive operations. 11.1.7.1 baudrates in asynchronous mode for asynchronous operation, the baudrate generator provides a clock f brt with 16 times the rate of the established baudrate. every received bit is sampled at the 7th, 8th and 9th cycle of this clock. the clock divider circuitry, which generates the input clock for the 13- bit baudrate timer, is extended by a fracxtional divider circuitry, which allows the adjustment of more accurate baudrates and the extension of the baudrate range. the baudrate of the baudrate generator depends on the following input clock, bits and register values : ? input clock f mod ? selection of the baudrate timer input clock f div by bits con_fde and con_brs ? if bit con_fde=1 (fractional divider) : value of register con_fdv ? value of the 13-bit reload register s0bg the output clock of the baudrate timer with the reload register is the sample clock in the asynchronous modes of the asc. for baudrate calculations, this baudrate clock f br is derived from the sample clock f div by a division by 16.
c165h asynchronous/synchr. serial interface data sheet 265 2001-04-19 p r e l i m i n a r y - exc er pt - figure 86 asc baudrate generator circuitry in asynchronous modes using the fixed input clock divider the baudrate for asynchronous operation of serial channel asc when using the fixed input clock divider ratios (con_fde=0) and the required reload value for a given baudrate can be determined by the following formulas : table 51 asynchronous baudrate formulas using the fixed input clock dividers fde brs bg formula 0 0 0 ... 8191 1 16 2 f mod baud rate clock sample clock r 13-bit reload register 13-bit baudrate timer 3 fractional divider mux fde brs fde brs selected divider 00 2 01 3 1 x fractional divider f div f brt f br 32 x (bg+1) baudrate = f mod 32 x baudrate f mod bg = - 1 48 x (bg+1) baudrate = f mod 48 x baudrate f mod bg = - 1
c165h asynchronous/synchr. serial interface data sheet 266 2001-04-19 p r e l i m i n a r y - exc er p t - bg represents the contents of the reload register s0bg (br_value), taken as unsigned 13-bit integer. the maximum baudrate that can be achieved for the asynchronous modes when using the two fixed clock dividers and a module clock of 36 mhz is 1.125 mbaud. table 52 below lists various commonly used baudrates together with the required reload values and the deviation errors compared to the intended baudrate. note: con_fde must be 0 to achieve the baudrates in the table above. the deviation errors given in the table above are rounded. using a baudrate crystal will provide correct baudrates without deviation errors. using the fractional divider when the fractional divider is selected, the input clock f div for the baudrate timer is derived from the module clock f mod by a programmable divider. if con_fde=1, the fractional divider is activated, it divides f mod by a fraction of n/512 for any value of n from 0 to 511. if n=0, the divider ratio is 1 which means that f div =f mod . in general, the fractional divider allows to program the baudrrate with a much better accuracy than with the two fixed prescaler divider stages. table 52 typical asynchronous baudrates using the fixed input clock dividers baudrate brs = ?0?, f mod = 36 mhz brs = ?1?, f mod = 36 mhz deviation error reload value deviation error reload value 1.125 mbaud --- 0000 h --- --- 750.0 kbaud --- --- --- 0000 h 19.2 kbaud - 0.69 % 003a h + 0.16 % 0026 h 9600 baud + 0.16 % 0074 h + 0.16 % 004d h 4800 baud + 0.16 % 00e9 h + 0.16 % 009b h 2400 baud + 0.16 % 01d3 h + 0.16 % 0137 h 1200 baud + 0.05 % 03a8 h +/- 0.0 % 0270 h table 53 asynchronous baudrate formulas using the fractional input clock divider fde brs bg fdv formula 1 x 1 ... 8191 1 ... 511 0 fdv 16 x (bg+1) baudrate = f mod 512 x 16 x (bg+1) baudrate = f mod
c165h asynchronous/synchr. serial interface data sheet 267 2001-04-19 p r e l i m i n a r y - exc er pt - bg represents the content of the reload register s0bg (br_value), taken as unsigned 13-bit integer. fdv represents the content of the fractional divider register s0fdv (fd_value) taken as unsigned 9-bit integer. for example, typical asynchronous baudrates are shown in table 54 . using the fractional divider and a module clock of 36 mhz (equal to the c165h cpu clock) the available baudrate range is 2.25 mbaud down to 0.5364 baud. . note: the apnote ap2423 provides a program ?asc.exe? which allows to calculate values for the s0fdv and s0bg registers depending on f mod , the requested baudrate, and the maximum deviation. please contact your infineon technologies representative. 11.1.7.2 baudrates in synchronous mode for synchronous operation, the baudrate generator provides a clock with 4 times the rate of the established baudrate.(see figure 87 ). table 54 typical asynchronous baudrates using the fractional input clock divider f mod desired baudrate bg fdv resulting baudrate deviation 36 mhz max. baudrate 0 0 2.25 mbaud 0 % 230.4 kbaud 6 367 230.399 kbaud < 0.01 % 115.2 kbaud 13 367 115.199 kbaud < 0.01 % 57.6 kbaud 27 367 57.5997 kbaud < 0.01 % 38.4 kbaud 41 367 38.3998 kbaud < 0.01 % 19.2 kbaud 83 367 19.1999 kbaud < 0.01 % min. baudrate 8191 1 0.53644 baud 0 %
c165h asynchronous/synchr. serial interface data sheet 268 2001-04-19 p r e l i m i n a r y - exc er p t - figure 87 asc baudrate generator circuitry in synchronous mode the baudrate for synchronous operation of serial channel asc can be determined by the formulas as shown in table 55 . bg represents the content of the reload register s0br (br_value), taken as unsigned 13-bit integers. the maximum baudrate that can be achieved in synchronous mode when using a module clock of 36 mhz is 4.5 mbaud. table 55 synchronous baudrate formulas brs bg formula 0 0 ... 8191 1 4 2 f mod shift / sample clock r 13-bit reload register 13-bit baudrate timer mux brs f div f brt brs selected divider 0 2 1 3 3 8 x (bg+1) baudrate = f mod 8 x baudrate f mod bg = - 1 12 x (bg+1) baudrate = f mod 12 x baudrate f mod bg = - 1
c165h asynchronous/synchr. serial interface data sheet 269 2001-04-19 p r e l i m i n a r y - exc er pt - 11.1.8 autobaud detection 11.1.8.1 general operation the autobaud detection unit in the asc provides a capability to recognize the mode and the baudrate of an asynchronous input signal at rxd. generally, the baudrates to be recognized must be known by the application. with this knowledge always a set of nine baudrates can be detected. the autobaud detection unit is not designed to calculate a baudrate of an unknown asynchronous frame. figure 88 shows how the autobaud detection unit of the asc is integrated into its asynchronous mode configuration. the rxd data line is an input to the autobaud detection unit. the clock f div which is generated by the fractional divider is used by the autobaud detection unit as time base. after successful recognition of baudrate and asynchronous operating mode of the rxd data input signal, bits in the s0con register and the value of the s0bg register in the baudrate timer are set to the appropriate values, and the asc can start immediately with the reception of serial input data. figure 88 asc asynchronous mode block diagram the following sequence must be generally executed to start the autobaud detection unit for operation : ? definition of the baudrates to be detected : standard or non-standard baudrates ? programming of the prescaler/fractional divider to select a specific value of f div ? starting the prescaler/fractional divider (setting con_r) ? preparing the interrupt system of the cpu ? enabling the autobaud detection (setting abcon_ en and the interrupt enable bits in abcon for interrupt generation, if required) ? polling interrupt request flag or waiting for the autobaud detection interrupt f mod baudrate timer serial port control receive / transmit buffers and shift registers irda coding mux irda decoding mux rxd txd prescaler / fractional divider asynchronous mode f div autobaud detection
c165h asynchronous/synchr. serial interface data sheet 270 2001-04-19 p r e l i m i n a r y - exc er p t - 11.1.8.2 serial frames for autobaud detection the autobaud detection of the asc is based on the serial reception of a specific two-byte serial frame. this serial frame is build up by the two ascii bytes "at" or "at" ("at" or "at" are not allowed). both byte combinations can be detected in five types of asynchronous frames. figure 89 and figure 90 show the serial frames which are detected at least. figure 89 two-byte serial frames with ascii ?at? 1000011001 0010111011 stop parity start stop parity start ?a? = 61 h ?t? = 74 h 1000011011 stop parity start ?a? = 61 h 0010111001 stop parity start ?t? = 74 h 8 bit, even parity 8 bit, odd parity 100001101 stop start ?a? = 61 h 001011111 start ?t? = 74 h 100001101 stop start ?a? = 61 h 001011101 stop start ?t? = 74 h 8 bit, no parity parity stop parity 7 bit, odd parity 100001111 stop start ?a? = 61 h 001011101 start ?t? = 74 h parity stop parity 7 bit, even parity
c165h asynchronous/synchr. serial interface data sheet 271 2001-04-19 p r e l i m i n a r y - exc er pt - figure 90 two-byte serial frames with ascii ?at? 1000001011 0010101001 stop parity start stop parity start ?a? = 41 h ?t? = 54 h 1000001001 stop parity start ?a? = 41 h 0010101011 stop parity start ?t? = 54 h 8 bit, even parity 8 bit, odd parity 100000111 stop start ?a? = 41 h 001010101 start ?t? = 54 h 100000101 stop start ?a? = 41 h 001010101 stop start ?t? = 54 h 8 bit, no parity parity stop parity 7 bit, odd parity 100000101 stop start ?a? = 41 h 001010111 start ?t? = 54 h parity stop parity 7 bit, even parity
c165h asynchronous/synchr. serial interface data sheet 272 2001-04-19 p r e l i m i n a r y - exc er p t - 11.1.8.3 baudrate selection and calculation the autobaud detection requires some calculations concerning the programming of the baudrate generator and the baudrates to be detected. two steps must be considered : ? defining the baudrate(s) to be detected ? programming of the baudrate timer prescaler - setup of the clock rate of f div in general, the baudrate generator of the asc in asynchronous mode is build up by two parts (see also figure 86 ) : ? the clock prescaler part which derives f div from f mod ? the baudrate timer part which generates the sample clock f brt and the baudrate clock f br prior to an autobaud detection the prescaler part has to be setup by the cpu while the baudrate timer (register bg) is initialized with a 13-bit value (br_value) automatically after a successfull autobaud detection. for the following calculations, the fractional divider is used (con_fde = 1). note: it is also possible to use the fixed divide-by-2 or divide-by-3 prescaler. but the fractional divider allows to adapt f div much more precise to the required value. standard baudrates for standard baudrate detection the baudrates as shown in table 56 can be e.g. detected. therefore, the output frequency f div of the asc baudrate generator must be set to a frequency derived from the module clock f mod in a way that it is equal to 11.0592 mhz. the value to be written into register fdv is the nearest integer value which is calculated according the following formula : table 56 defines the nine standard baudrates (br0 - br8) which can be detected for f div =11.0592 mhz. table 56 autobaud detection using standard baudrates (f div = 11.0592 mhz) baudrate numbering detectable standard baudrate divide factor d f bg is loaded after detection with value br0 230.400 kbaud 48 2 = 002 h br1 115.200 kbaud 96 5 = 005 h br2 57.600 kbaud 192 11 = 00b h br3 38.400 kbaud 288 17 = 011 h br4 19.200 kbaud 576 35 = 023 h fdv = 512 x 11.0592 mhz f mod
c165h asynchronous/synchr. serial interface data sheet 273 2001-04-19 p r e l i m i n a r y - exc er pt - according table 56 a baudrate of 9600 baud is achieved when register bg is loaded with a value of 047 h , assuming that f div has been set to 11.0592 mhz. table 56 also lists a divide factor d f which is defined with the following formula : this divide factor d f defines a fixed relationship between the prescaler output frequency f div and the baudrate to be detected during the autobaud detection operation. this means, changing f div results in a totally different baudrate table in means of baudrate values. for the baudrates to be detected, the following relations are always valid : ?br0 = f div / 48 d , br1 = f div / 96 d , ....... up to br8 = f div / 9216 d , a requirement for detecting standard baudrates up to 230.400 kbaud is the f div minimum value of 11.0592 mhz. with the value fd_value in register fdv the fractional divider f div is adapted to the module clock frequency f mod . table 57 defines the deviation of the standard baudrates when using autobaud detection depending on the module clock f mod . br5 9600 baud 1152 71 = 047 h br6 4800 baud 2304 143 = 08f h br7 2400 baud 4608 287 = 11f h br8 1200 baud 9216 575 = 23f h table 57 standard baudrates - deviations and errors for autobaud detection f mod fdv error in f div 10 mhz not possible 12 mhz 472 + 0.03 % 13 mhz 436 + 0.1 % 16 mhz 354 + 0.03 % 18 mhz 315 + 0.14 % 18.432 mhz 307 - 0.07 % 20 mhz 283 - 0.04 % 24 mhz 236 + 0.03 % 25 mhz 226 - 0.22 % 30 mhz 189 + 0.14 % 33 mhz 172 + 0.24 % 36 mhz 157 + 0.18 % table 56 autobaud detection using standard baudrates (f div = 11.0592 mhz) baudrate numbering detectable standard baudrate divide factor d f bg is loaded after detection with value baudrate = f div d f
c165h asynchronous/synchr. serial interface data sheet 274 2001-04-19 p r e l i m i n a r y - exc er p t - note: if the deviation of the baudrate after autobaud detection is to high, the baudrate generator (fractional divider fdv and reload register bg) can be reprogrammed if required to get a more precise baudrate with less error. non-standard baudrates due to the relationship between br0 to br8 in table 56 concerning the divide factor d f other baudrates than the standard baudrates can be also selected. e.g. if a baudrate of 50 kbaud has to be detected, br2 is e.g. defined as baudrate for the 50 kbaud setection. this further results in : ?f div = 50 kbaud x d f @br2 = 50 kbaud x 192 = 9.6 mhz therefore, depending on the module clock frequency f mod , the value of the fractional divider (register s0fdv must be set in this example according the formula : using this selection (f div = 9.6 mhz), the detectable baudrates start at 200 kbaud (br0) down to 1042 baud (br8). table 58 shows the baudrate table for this example. 11.1.8.4 overwriting registers on successful autobaud detection with a successfull autobaud detection some bits in register s0con and s0bg are automatically set to a value which corresponds to the mode and baudrate of the detected serial frame conditions (see table 59 ). in control register s0con the mode control bits table 58 autobaud detection using non-standard baudrates (f div = 9.6 mhz) baudrate numbering detectable non-standard baudrates divide factor d f bg is loaded after detection with value br0 200.000 kbaud 48 2 = 002 h br1 100.000 kbaud 96 5 = 005 h br2 50 kbaud 192 11 = 00b h br3 33.333 kbaud 288 17 = 011 h br4 16.667 kbaud 576 35 = 023 h br5 8333 baud 1152 71 = 047 h br6 4167 baud 2304 143 = 08f h br7 2083 baud 4608 287 = 11f h br8 1047 baud 9216 575 = 23f h fdv = 512 x f div f mod with f div = 9.6 mhz
c165h asynchronous/synchr. serial interface data sheet 275 2001-04-19 p r e l i m i n a r y - exc er pt - con_m and the parity select bit con_odd are overwritten. register s0bg is loaded with the 13-bit reload value for the baudrate timer. note: the autobaud detection interrupts are described in chapter 11.1.10. 11.1.9 hardware error detection capabilities to improve the safety of serial data exchange, the serial channel asc provides an error interrupt request flag, which indicates the presence of an error, and three (selectable) error status flags in register s0con, which indicate which error has been detected during reception. upon completion of a reception, the error interrupt request line eir will be activated simultaneously with the receive interrupt request line rir, if one or more of the following conditions are met : ? the framing error detection enable bit con_fen is set and any of the expected stop bits is not high, the framing error flag con_fe is set, indicating that the error interrupt request is due to a framing error (asynchronous mode only). ? if the parity error detection enable bit con_pen is set in the modes where a parity bit is received, and the parity check on the received data bits proves false, the parity error flag con_pe is set, indicating that the error interrupt request is due to a parity error (asynchronous mode only). ? if the overrun error detection enable bit con_oen is set and the last character received was not read out of the receive buffer by software or pec (dma) transfer at the time the reception of a new frame is complete, the overrun error flag con_oe is set indicating that the error interrupt request is due to an overrun error (asynchronous and synchronous mode). table 59 autobaud detection overwrite values for the s0con register detected parameters con_m con_odd bg_br_value operating mode 7 bit, even parity 7 bit, odd parity 8 bit, even parity 8 bit, odd parity 8 bit, no parity 0 1 1 0 1 1 1 1 1 1 1 1 0 0 1 0 1 0 1 0 - baudrate br0 br1 br2 br3 br4 br5 br6 br7 br8 - - 2 = 002 h 5 = 005 h 11 = 00b h 17 = 011 h 35 = 023 h 71 = 047 h 143 = 08f h 287 = 11f h 575 = 23f h
c165h asynchronous/synchr. serial interface data sheet 276 2001-04-19 p r e l i m i n a r y - exc er p t - 11.1.10 interrupts six interrupt sources are provided for serial channel asc. line tir indicates a transmit interrupt, tbir indicates a transmit buffer interrupt, rir indicates a receive interrupt and eir indicates an error interrupt of the serial channel. the autobaud detection unit provides two additional interrupts, the abstir start of autobaud operation interrupt and the abdetir autobaud detected interrupt. the interrupt output lines tbir, tir, rir, eir, abstir, and abdetir are activated (active state) for two periods of the module clock f mod five. the cause of an error interrupt request (framing, parity, overrun error) can be identified by the error status flags fe, pe, and oe which are located in control register con. for the two autobaud detection interrupts register abstat provides status information. note: in contrary to the error interrupt request line eir, the error status flags fe/pe/oe are not reset automatically but must be cleared by software. for normal operation (ie. besides the error interrupt) the asc provides three interrupt requests to control data exchange via this serial channel: ? tbir is activated when data is moved from tbuf to the transmit shift register. ? tir is activated before the last bit of an asynchronous frame is transmitted, or after the last bit of a synchronous frame has been transmitted. ? rir is activated when the received frame is moved to rbuf. the transmitter is serviced by two interrupt handlers. this provides advantages for the servicing software. for single transfers, it is sufficient to use the transmitter interrupt (tir), which indicates that the previously loaded data has been transmitted, except for the last bit of an asynchronous frame. for multiple back-to-back transfers it is necessary to load the following piece of data at last until the time the last bit of the previous frame has been transmitted. in asynchronous mode this leaves just one bit-time for the handler to respond to the transmitter interrupt request, in synchronous mode it is impossible at all. using the transmit buffer interrupt (tbir) to reload transmit data gives the time to transmit a complete frame for the service routine, as tbuf may be reloaded while the previous data is still being transmitted. the abstir start of autobaud operation interrupt is generated whenever the autobaud detection unit is enabled (aben and abdeten and absten set), and a start bit has been detected at rxd. in this case abstir is generated during autobaud detection whenever a start bit is detected. the abdetir autobaud detected interrupt is always generated after recognition of the second character of the two-byte frame, this means after a successful autobaud detection. if abcon_fcdeten is set the abdetir autobaud detected interrupt is also generated after the recognition of the first character of the two-byte frame.
c165h asynchronous/synchr. serial interface data sheet 277 2001-04-19 p r e l i m i n a r y - exc er pt - figure 91 asc interrupt generation as shown in figure 91 , tbir is an early trigger for the reload routine, while tir indicates the completed transmission. software using handshake therefore should rely on tir at the end of a data block to make sure that all data has really been transmitted. idle idle start start start stop stop stop idle idle asynchronous mode tbir tbir tir tbir tir rir rir synchronous mode tbir rir tbir tir rir tbir tir rir tir rir tir idle start stop asynchronous modes abdetir 1) autobaud detection abstir 1) only if fcdeten=1 1. character start stop 2. character abdetir
c165h real time clock (rtc) data sheet 278 2001-04-19 p r e l i m i n a r y - exc er p t - 12 real time clock (rtc) 12.1 introduction the real time clock (rtc) module of the c165h basically is an independent timer chain and counts time ticks. the base frequency of the rtc can be programmed via a reload counter. the rtc can work fully asynchronous to the system frequency and is optimized on low power consumption. 12.1.1 features the rtc serves for different purposes: ? system clock to determine the current time and date ? cyclic time based interrupt ? alarm interrupt for wake up on a defined time ? 48-bit timer for long term measurements 12.1.2 overview the real time clock module provides three different types of registers: two control registers for controlling the rtcs functionality, three data registers for setting the clock divider for rtc base frequency programming and for flexible interrupt generation, and three counter registers they contain the actual time and date. the interrupts are programmed via one interrupt sub node register. 12.2 function description the rtc module consists of a chain of 2 divider blocks, the reloadable 16-bit timer t14 and the 32-bit rtc timer (accessible via registers rtch and rtcl). both timers count up. timer t14 is reloaded with the value of register t14rel on every timer t14 overflow. the count input of the rtc module (rtc_ref_clk) can be optional divided by a prescaler with factor 8, see figure 93 . the rtc module operates in two different modes, an asynchronous and a synchronous mode. in synchronous mode the rtc module is clocked with a synchronous clock referring to the cpu clock (rtc clock). in asynchronous mode the rtc module is clocked with the asynchronous counting input clock (rtc_ref_clk). the asynchronous mode is necessary in case of a very low or disabled cpu clock (eg. sleep mode). the mode control (asynchronous / synchronous) of the rtc is described as follows:  the rtc is switched to asynchronous mode if syscon2.rcs = '1'  the rtc is switched to asynchronous mode if device is in sleep mode.
c165h real time clock (rtc) data sheet 279 2001-04-19 p r e l i m i n a r y - exc er pt -  rtc is switched to asynchronous mode if the system is not in slowdown mode and the system clock is not locked (observe selected clk_cfg as set during reset). this means that the mode is controlled by bit rcs of register syscon2 (see page 428) unless the system's clock setting indicates that no or an unreliable cpu clock is available. in the latter case, synchronous mode is not working and thus the rtc is forced into asynchronous mode. as long as the cpu clock is four times faster than the rtc_ref_clk, the rtc module can be operated in synchronous mode. otherwise the asynchronous mode has to be selected by software. in asynchronous mode no writing but only asynchronous reading to the registers via the internal bus is possible. 12.2.1 rtc block diagram figure 92 shows the rtc block diagram: figure 92 rtc block diagram t14rel (16 bit) t14 (16 bit) rtc_ref_clk 6 bit rtcl rtcrell 10 bit 10 bit 6 bit 10 bit rtch rtcrelh 6 bit 6 bit 10 bit rtc_t14int xb(3) interrupt sub node rtcisnc rtc_int irq(15) and rtc3int rtc2int rtc1int rtc0int mux 8:1 rtcpre rtcr t14_in altern. source fast ext. interrupt 7
c165h real time clock (rtc) data sheet 280 2001-04-19 p r e l i m i n a r y - exc er p t - 12.2.2 rtc control the operating behaviour of the rtc module is controlled by the rtccon register. the rtc starts counting by setting the run bit rtcr. after reset the run bit is set and the rtc automatically starts operation. the bit rtcpre selects a prescaler which divides the counting clock by factor 8. activating the prescaler reduces the resolution of the reload counter t14. if the prescaler is not activated, the rtc may be lose counting clocks on switching from asynchronous to synchronous mode and back. this effect can be avoided by activating the prescaler. setting the bits t14dec or t14inc decrements or increments the t14 timer with the next count event. if at the next count event a reload has to be executed, then an increment operation is delayed until the next count event occurs. the in/decrement function can only be used if register t14rel is not equal to ffff h . these bits are cleared by hardware after the decrement/increment operation. 12.2.3 system clock operation a real time system clock can be maintained that represents the current time and date. if the rtc module is not effected by a system reset, it keeps running also during idle mode and power down mode. the maximum resolution (minimum stepwidth) for this clock information is determined by timer t14?s input clock. the maximum usable timespan is achieved when t14rel is loaded with 0000 h and so t14 divides by 2 16 . 12.2.4 cyclic interrupt generation the rtc module can generate an interrupt request rtc_t14int whenever timer t14 overflows and is reloaded. this interrupt request may eg. be used to provide a system time tick independent of the cpu clock frequency without loading the general purpose timers, or to wake up regularly from idle mode. the t14 overflow interrupt (rtc_t14int) cycle time can be adjusted via the timer t14 reload register t14rel. this interrupt request is also ored with all other interrupts of the rtc via the rtc interrupt sub node rtcisn. 12.2.5 alarm interrupt generation the rtc module can also provide an alarm interrupt. for an easier programming of this interrupt, the rtcl and rtch timer can be divided into smaller reloadable timers. each sub-timer can be programmed for an overflow on different time bases (e.g. second, hour, minute, day). with each timer overflow a rtc interrupt is generated. all these rtc interrupts are ored via the interrupt sub node rtcisnc to one interrupt request rtc_int. additionally the rtc_t14int is connected to this interrupt sub node.
c165h real time clock (rtc) data sheet 281 2001-04-19 p r e l i m i n a r y - exc er pt - 12.2.6 48-bit timer operation the concatenation of the 16-bit reload timer t14 and the 32-bit rtc timer can be regarded as a 48-bit timer which counts with the rtc count input frequency (rtc_ref_clk) divided by the fixed prescaler, if the prescaler is selected. the reload registers t14rel, rtcrell and rtcrelh should be cleared to get a 48-bit binary timer. however, any other reload values may be used. the maximum usable timespan is 2 48 ( 10 14 ) t14 input clocks, which equals more than 100 years (referring to a rtc count input frequency rtc_ref_clk of 625 khz, which is equal to a 20 mhz oscillator divided by 32, and an activated prescaler). 12.2.7 defining the rtc time base the count input of the rtc module (rtc_ref_clk) is connected as shown in figure 93 . the rtc timer base is equal to timer t14 overflow and depends on the selectable prescaler and on the reload counter t14. figure 93 rtc module clocking scheme the table below lists the rtc_t14int interrupt period range for several rtc count input frequencies: table 60 rtc interrupt periods oscillator frequency divider factor rtc input frequency prescaler factor rtc_t14int period minimum maximum 32 khz 1 32 khz 31.25 s 2.048 s 1 mhz 32 312.5 khz 8 256.0 s 16.77 s 4 mhz 32 125 khz 8 64.0 s 4.194 s rtcmoduleclk001 rtc timer 32 bit t14 16 bit m u x 8:1 m u x 32:1 osc rtc_clk_sel xtal2 cpu_clock rtc_ref_clk xtal1 rtc_t14int rtc_int rtc module (simple drawing)
c165h real time clock (rtc) data sheet 282 2001-04-19 p r e l i m i n a r y - exc er p t - table 61 lists the t14 reload values for a time base of 1 s (a), 100 ms (b) and 1 ms (c) and several rtc input frequencies: 5 mhz 32 19.531 khz 8 51.2 s 3.355 s 8 mhz 32 156.25 khz 8 32.0 s 2.097 s 10 mhz 32 312.5 khz 8 25.6 s 1.678 s 12 mhz 32 375 khz 8 21.3 s 1.398 s 16 mhz 32 500 khz 8 16.0 s 1.049 s 20 mhz 32 625 khz 8 12.8 s 0.839 s 24 mhz 32 750 khz 8 10.67 s 0.699 s 25 mhz 32 781.25 khz 8 10.24 s 0.671 s 32 mhz 32 1 mhz 8 8.0 s 0.524 s 50 mhz 32 1.56 mhz 8 5.12 s 0.336 s table 61 rtc reload values rtc input frequency reload value a reload value b reload value c t14rel base t14rel base t14rel base 32 khz 8300 h 1.000 s f380 h 100.0 ms ffe0 h 1.000 ms 312.5 khz f0be h 0.999 s fe79 h 100.1 ms fffc h 1.024 ms 125 khz c2f7 h 1.000 s f9e5 h 100.0 ms fff0 h 1.024 ms 19.531 khz b3b5 h 0.999 s f85f h 99.9 ms ffec h 1.024 ms 156.25 khz 85ee h 1.000 s f3cb h 100.0 ms ffe1 h 0.992 ms 312.5 khz 6769 h 1.000 s f0be h 99.9 ms ffd9 h 0.998 ms 375 khz 48e5 h 1.000 s edb0 h 100.0 ms ffd1 h 1.003 ms 500 khz 0bdc h 1.000 s e796 h 100.0 ms ffc1 h 1.008 ms 625 khz e17b h 100.0 ms ffb2 h 0.998 ms 750 khz db61 h 100.0 ms ffa2 h 1.003 ms 781.25 khz d9da h 100.0 ms ff9e h 1.004 ms 1 mhz cf2c h 100.0 ms ff83 h 1.000 ms 1.56 mhz b3b5 h 99.9 ms ff3d h 0.998 ms table 60 rtc interrupt periods (cont?d) oscillator frequency divider factor rtc input frequency prescaler factor rtc_t14int period minimum maximum
c165h real time clock (rtc) data sheet 283 2001-04-19 p r e l i m i n a r y - exc er pt - 12.2.8 increased rtc accuracy through software correction the accuracy of the c165h?s rtc is determined by the oscillator frequency and by the respective prescaling factor (excluding or including t14 and the selectable prescaler). the accuracy limit generated by the prescaler is due to the quantization of a binary counter (where the average is zero), while the accuracy limit generated by the oscillator frequency is due to the difference between ideal and real frequency (and therefore accumulates over time). the total accuracy of the rtc can be further increased via software for specific applications that demand a high time accuracy. the key to the improved accuracy is the knowledge of the exact oscillator frequency. the relation of this frequency to the expected ideal frequency is a measure for the rtc?s deviation. the number n of cycles after which this deviation causes an error of 1 cycle can be easily computed. so the only action is to correct the count by 1 after each series of n cycles. this correction may be applied to the rtc register as well as to t14. also the correction may be done cyclic, eg. within t14?s interrupt service routine, or by evaluating a formula when the rtc registers are read (for this the respective ?last? rtc value must be available somewhere). t14 can be adjusted by a write access or better by using the in/ decrement function provided by the rtccon register. note: for the majority of applications, however, the standard accuracy provided by the rtc?s structure will be more than sufficient. 12.2.9 hardware dependend rtc accuracy the rtc has different counting accuracies, depending on the operating mode (with or without prescaler). there is only an impact on the counting accuracy when switching the rtc from synchronous mode to asynchronous mode and back. . 12.2.10 interrupt sub node rtcisnc all rtc interrupts are connected to one interrupt node via an interrupt sub node. for this interrupt sharing each interrupt source has additionally to the node enable and request flag its own enable and request flag located in register rtcisnc. after a rtc interrupt (rtc_int) is arbitrated, the interrupt service routine has to check the request flags of all enabled sources and run the respective software routine. the request flags have to be deleted by software before leaving the interrupt service routine. table 62 impact on counting accuracy operating mode inaccuracy in t14 counting ticks without prescaler +0 / -0.5 with prescaler +0 / -0
c165h real time clock (rtc) data sheet 284 2001-04-19 p r e l i m i n a r y - exc er p t - the following figure shows the additional necessary differentiating circuits for the interrupt logic: figure 94 differentiating circuits for rtc interrupt 12.2.11 rtc disable functionality the peripheral kernel of the rtc can be disabled, if the rtc functionality is not used. in this case only the bus interface is enabled. disabling the rtc module reduces the power consumption and the generated noise of the complete system. the disable request can be set in two different ways. the bit rtcdis (if implemented in c165h) of the central peripheral control register syscon3 controls the disable request of the rtc module. additional the request can be set with bit rtcdisr inside the rtc clock control register (rtcclc). the central and the local disable requests are ored. clearing the respective disable request flag enables the rtc module again. note that both request flags have to be cleared for enabling the rtc module. an activated request flag sets directly the disabling status flag rtcdiss inside the rtcclc register and disables the clock within the clock gating module. since the rtcclc register is clocked with the diff. circuit rtcisnc & pulse generation & 1 note: 1) the isr (interrupt service routine) must delete the ir flag in register rtcisnc manually. otherwise no further interrupts can be detected. t14 rtc0int diff. circuit rtc_t14int & diff. circuit rtc3int diff. circuit & rtc1int diff. circuit & rtc2int ie t14 ir 1) rtc0 ie rtc0 ir 1) rtc1 ie rtc1 ir 1) rtc2 ie rtc2 ir 1) rtc3 ie rtc3 ir 1)
c165h real time clock (rtc) data sheet 285 2001-04-19 p r e l i m i n a r y - exc er pt - bus clock, the disabling status of the rtc can be read and the rtc can be enabled again. the following figure shows the disabling mechanism of the rtc module: figure 95 disabling mechanism of the rtc in disable state no write access to rtc registers is possible. the only exeption is the rtcclc register. 12.2.12 register definition of rtc module the following table shows the register addresses map: table 63 address map overview sfr address b/p register name f0c8 h rtcclc f1cc h b rtccon f0d0 h t14rel f0d2 h t14 f0d4 h rtcl f0d6 h rtch f0cc h rtcrell f0ce h rtcrelh f1c8 h b/p rtcisnc rtc disr rtc diss 0 1 3 15 rtcclc rtc module rtc_ex_disr ocds_p_suspend susp en 2 exr dis clock gating rtc_dis_n
c165h real time clock (rtc) data sheet 286 2001-04-19 p r e l i m i n a r y - exc er p t - b : b itaddressable p : bit p rotected rtc clock control register rtcclc (f0c8 h ) reset value: 0000 h bit function rtcdisr rtc disable request bit rtcdisr = ? 0 ? : rtc clock disable not requested rtcdisr = ? 1 ? : rtc clock disable requested rtcdiss rtc disable status bit rtcdiss = ? 0 ? : rtc clock enabled rtcdiss = ? 1 ? : rtc clock disabled suspen peripheral suspend enable bit for ocds suspen = ? 0 ? : peripheral suspend disabled suspen = ? 1 ? : peripheral suspend enabled exdisr external disable request exrdis = ? 0 ? : external clock disable request is enabled exrdis = ? 1 ? : external clock disable request is disabled 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rtc disr rtc diss 0 0 0 0 0 0 rw r rw rw 0 0 0 0 0 0 sus pen ex disr
c165h real time clock (rtc) data sheet 287 2001-04-19 p r e l i m i n a r y - exc er pt - rtc control register rtccon (f1cc h ) bitaddressablereset value:0003 h note : for compatibility reasons the bits rtcr and rtcpre are set on asynchronous hw reset (power on reset). prescaler timer t14 timer t14 generates the input clock for the rtc register and the periodic interrupt t14 (f0d2 h ) reset value:0000 h bit function rtcr rtc run bit rtcr = ? 0 ? : rtc stops rtcr = ? 1 ? : rtc runs rtcpre rtc input source prescaler enable rtcpre = ? 0 ? : input prescaler disabled rtcpre = ? 1 ? : input prescaler enabled t14dec decrement t14 timer value setting this bit to 1 effects a decrement of the t14 timer value. the bit is cleared by hardware after decrementation. t14inc increment t14 timer value setting this bit to 1 effects an increment of the t14 timer value. the bit is cleared by hardware after incrementation. accpos rtc register access possible this bit indicates that a synchronous read / write access to rtc registers is possible. the clock control register rtcclc can allways be accessed. accpos = ? 0 ? : no write access is possible, only asynchronous reads. accpos = ? 1 ? : read / write access is possible 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rtc r rtc pre 0 0 0 0 0 rw rw rw rw r 0 0 0 0 0 t14 dec t14 inc acc pos 0 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12
c165h real time clock (rtc) data sheet 288 2001-04-19 p r e l i m i n a r y - exc er p t - timer t14 reload register t14rel (f0d0 h ) reset value:0000 h rtc count register low word rtcl (f0d4 h ) reset value:0000 h rtc count register high word rtch (f0d6 h ) reset value:0000 h rtc reload register low word rtcrell (f0cc h ) reset value:0000 h rtc reload register high word rtcrelh (f0ce h ) reset value:0000 h 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12
c165h real time clock (rtc) data sheet 289 2001-04-19 p r e l i m i n a r y - exc er pt - rtc interrupt sub node control rtcisnc (f1c8 h ) bitaddressablereset value:uuuu h note : the interrupt request flags of the rtc interrupt sub node have to be cleared by software inside the interrupt service routine. bit function t14ie t14 overflow interrupt enable control bit ? 0 ? : interrupt request is disabled ? 1 ? : interrupt request is enabled t14ir t14 overflow interrupt request flag (bit protected) ? 0 ? : no request pending ? 1 ? : this source has raised an interrupt request rtcxie rtcx interrupt enable control bit ? 0 ? : interrupt request is disabled ? 1 ? : interrupt request is enabled rtcxir rtcx interrupt request flag (bit protected) ? 0 ? : no request pending ? 1 ? : this source has raised an interrupt request 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw t14 ie t14 ir rtc 0ie rtc 0 ir rtc 1ie rtc 1 ir rtc 2ie rtc 2 ir 0 0 0 0 0 0 rw rw rw rw rw rw rw rtc 3ie rtc 3 ir
c165h high-speed synchronous serial interface data sheet 290 2001-04-19 p r e l i m i n a r y - exc er p t - 13 high-speed synchronous serial interface the high-speed synchronous serial interface ssc provides flexible high-speed serial communication between the c165h and other microcontrollers, microprocessors or external peripherals. the ssc supports full-duplex and half-duplex synchronous communication up to 18 mbaud in ssc master mode and 9 mbaud in ssc slave mode (@ 36 mhz cpu clock). the serial clock signal can be generated by the ssc itself (master mode) or be received from an external master (slave mode). data width, shift direction, clock polarity and phase are programmable. this allows communication with spi-compatible devices. transmission and reception of data is double-buffered. a 16-bit baud rate generator provides the ssc with a separate serial clock signal. the high-speed synchronous serial interface can be configured in a very flexible way, so it can be used with other synchronous serial interfaces (eg. the asc in synchronous mode), serve for master/slave or multimaster interconnections or operate compatible with the popular spi interface. so it can be used to communicate with shift registers (io expansion), peripherals (eg. eeproms etc.) or other controllers (networking). the ssc supports half-duplex and full-duplex communication. data is transmitted or received on pins mtsr/p3.9 (master transmit / slave receive) and mrst/p3.8 (master receive / slave transmit). the clock signal is output or input on pin sclk/p3.13. these pins are alternate functions of port 3 pins. figure 96 sfrs and port pins associated with the ssc sclk / p3.13 mtsr / p3.9 mrst / p3.8 sscclc ssc clock control register odp3 port 3 open drain control register dp3 port 3 direction control register sscbr ssc baud rate generator/reload register ssctb ssc transmit buffer register ssctic ssc transmit interrupt control register p3 port 3 data register ssccon ssc control register sscrb ssc receive buffer register sscric ssc receive interrupt control register ssceic ssc error interrupt control register odp3 ports & direction control alternate functions system data registers control registers interrupt control sscbr ssccon ssctic dp3 p3 ssctb sscrb sscric ssceic sscclc
c165h high-speed synchronous serial interface data sheet 291 2001-04-19 p r e l i m i n a r y - exc er pt - figure 97 synchronous serial channel ssc block diagram the operating mode of the serial channel ssc is controlled by its bit-addressable control register ssccon. this register serves for two purposes:  during programming (ssc disabled by sscen=?0?) it provides access to a set of control bits  during operation (ssc enabled by sscen=?1?) it provides access to a set of status flags register ssccon is shown below in each of the two modes. mcb01957 receive int. request transmit int. request error int.request ssc control block 16-bit shift register transmit buffer register ssctb register sscrb receive buffer pin control status control shift clock generator baud rate clock control slave clock master clock cpu clock i n t e r n a l b u s mtsr mrst sclk
c165h high-speed synchronous serial interface data sheet 292 2001-04-19 p r e l i m i n a r y - exc er p t - ssccon (ffb2 h / d9 h ) sfr reset value: 0000 h bit function (programming mode, sscen = ? 0 ? ) sscbm ssc data width selection 0 : reserved. do not use this combination. 1...15 : transfer data width is 2...16 bit (+1) sschb ssc heading control bit 0 : transmit/receive lsb first 1 : transmit/receive msb first sscph ssc clock phase control bit 0 : shift transmit data on the leading clock edge, latch on trailing edge 1 : latch receive data on leading clock edge, shift on trailing edge sscpo ssc clock polarity control bit 0 : idle clock line is low, leading clock edge is low-to-high transition 1 : idle clock line is high, leading clock edge is high-to-low transition sscten ssc transmit error enable bit 0 : ignore transmit errors 1 : check transmit errors sscren ssc receive error enable bit 0 : ignore receive errors 1 : check receive errors sscpen ssc phase error enable bit 0 : ignore phase errors 1 : check phase errors sscben ssc baudrate error enable bit 0 : ignore baudrate errors 1 : check baudrate errors sscaren ssc automatic reset enable bit 0 : no additional action upon a baudrate error 1 : the ssc is automatically reset upon a baudrate error sscms ssc master select bit 0 : slave mode. operate on shift clock received via sclk. 1 : master mode. generate shift clock and output it via sclk. sscen ssc enable bit = ? 0 ? transmission and reception disabled. access to control bits. 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw - rw rw rw - rw - ssc hb ssc ph ssc po rw rw ssc ben ssc en=0 ssc ms ssc pen ssc ren ssc ten - sscbm ssc aren
c165h high-speed synchronous serial interface data sheet 293 2001-04-19 p r e l i m i n a r y - exc er pt - ssccon (ffb2 h / d9 h ) sfr reset value: 0000 h note:  the target of an access to ssccon (control bits or flags) is determined by the state of sscen prior to the access, ie. writing c057 h to ssccon in programming mode (sscen=?0?) will initialize the ssc (sscen was ?0?) and then turn it on (sscen=?1?).  when writing to ssccon, make sure that reserved locations receive zeros. the shift register of the ssc is connected to both the transmit pin and the receive pin via the pin control logic (see block diagram). transmission and reception of serial data is synchronized and takes place at the same time, ie. the same number of transmitted bits is also received. transmit data is written into the transmit buffer ssctb. it is moved to the shift register as soon as this is empty. an ssc-master (sscms=?1?) immediately begins transmitting, while an ssc-slave (sscms=?0?) will wait for an active shift clock. when the transfer starts, the busy flag sscbsy is set and a transmit interrupt request (ssctir) will be generated to indicate that ssctb may be reloaded again. when the programmed number of bits (2...16) has been transferred, the contents of the shift register are moved to the receive buffer sscrb and a receive interrupt request bit function (operating mode, sscen = ? 1 ? ) sscbc ssc bit count field shift counter is updated with every shifted bit. do not write to!!! sscte ssc transmit error flag 1 : transfer starts with the slave ? s transmit buffer not being updated sscre ssc receive error flag 1 : reception completed before the receive buffer was read sscpe ssc phase error flag 1 : received data changes around sampling clock edge sscbe ssc baudrate error flag 1 : more than factor 2 or 0.5 between slave ? s actual and expected baudrate sscbsy ssc busy flag set while a transfer is in progress. do not write to!!! sscms ssc master select bit 0 : slave mode. operate on shift clock received via sclk. 1 : master mode. generate shift clock and output it via sclk. sscen ssc enable bit = ? 1 ? transmission and reception enabled. access to status flags and m/s control. 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 - - r rw rw - - rw rw - rw - rw rw ssc be ssc en=1 ssc ms ssc pe ssc re ssc te - ssc bsy --- sscbc
c165h high-speed synchronous serial interface data sheet 294 2001-04-19 p r e l i m i n a r y - exc er p t - (sscrir) will be generated. if no further transfer is to take place (ssctb is empty), sscbsy will be cleared at the same time. software should not modify sscbsy, as this flag is hardware controlled. note: only one ssc (etc.) can be master at a given time. the transfer of serial data bits can be programmed in many respects:  the data width can be chosen from 2 bits to 16 bits  transfer may start with the lsb or the msb  the shift clock may be idle low or idle high  data bits may be shifted with the leading or trailing edge of the clock signal  the baudrate may be set from 274.7 baud up to 18 mbaud (@ 36 mhz cpu clock)  the shift clock can be generated (master) or received (slave) this allows the adaptation of the ssc to a wide range of applications, where serial data transfer is required. the data width selection supports the transfer of frames of any length, from 2-bit ?characters? up to 16-bit ?characters?. starting with the lsb (sschb=?0?) allows communication eg. with asc devices in synchronous mode (c166 family) or 8051 like serial interfaces. starting with the msb (sschb=?1?) allows operation compatible with the spi interface. regardless which data width is selected and whether the msb or the lsb is transmitted first, the transfer data is always right aligned in registers ssctb and sscrb, with the lsb of the transfer data in bit 0 of these registers. the data bits are rearranged for transfer by the internal shift register logic. the unselected bits of ssctb are ignored, the unselected bits of sscrb will be not valid and should be ignored by the receiver service routine. the clock control allows the adaptation of transmit and receive behaviour of the ssc to a variety of serial interfaces. a specific clock edge (rising or falling) is used to shift out transmit data, while the other clock edge is used to latch in receive data. bit sscph selects the leading edge or the trailing edge for each function. bit sscpo selects the level of the clock line in the idle state. so for an idle-high clock the leading edge is a falling one, a 1-to-0 transition. the figure below is a summary.
c165h high-speed synchronous serial interface data sheet 295 2001-04-19 p r e l i m i n a r y - exc er pt - figure 98 serial clock phase and polarity options 13.1 full-duplex operation the different devices are connected through three lines. the definition of these lines is always determined by the master: the line connected to the master's data output pin mtsr is the transmit line, the receive line is connected to its data input line mrst, and the clock line is connected to pin sclk. only the device selected for master operation generates and outputs the serial clock on pin sclk. all slaves receive this clock, so their pin sclk must be switched to input mode (dp3.13=?0?). the output of the master?s shift register is connected to the external transmit line, which in turn is connected to the slaves? shift register input. the output of the slaves? shift register is connected to the external receive line in order to enable the master to receive the data shifted out of the slave. the external connections are hard-wired, the function and direction of these pins is determined by the master or slave operation of the individual device. note: the shift direction shown in the figure applies for msb-first operation as well as for lsb-first operation. when initializing the devices in this configuration, select one device for master operation (sscms=?1?), all others must be programmed for slave operation (sscms=?0?). initialization includes the operating mode of the device's ssc and also the function of the respective port lines (see ?port control?). mcd01960 last bit transmit data first bit latch data shift data pins mtsr/mrst serial clock sclk sscpo sscph 00 0 1 1 0 11
c165h high-speed synchronous serial interface data sheet 296 2001-04-19 p r e l i m i n a r y - exc er p t - figure 99 ssc full duplex configuration the data output pins mrst of all slave devices are connected together onto the one receive line in this configuration. during a transfer each slave shifts out data from its shift register. there are two ways to avoid collisions on the receive line due to different slave data: only one slave drives the line , ie. enables the driver of its mrst pin. all the other slaves have to program there mrst pins to input. so only one slave can put its data onto the master's receive line. only receiving of data from the master is possible. the master selects the slave device from which it expects data either by separate select lines, or by sending a special command to this slave. the selected slave then switches its mrst line to output, until it gets a deselection signal or command. the slaves use open drain output on mrst . this forms a wired-and connection. the receive line needs an external pullup in this case. corruption of the data on the receive line sent by the selected slave is avoided, when all slaves which are not selected for transmission to the master only send ones (?1?). since this high level is not actively driven onto the line, but only held through the pullup device, the selected slave can pull this line actively to a low level when transmitting a zero bit. the master selects the slave device mcs01963 mrst sclk device #2 slave clock shift register mtsr clock master receive transmit device #1 clock mtsr mrst sclk shift register mtsr shift register clock slave sclk mrst device #3
c165h high-speed synchronous serial interface data sheet 297 2001-04-19 p r e l i m i n a r y - exc er pt - from which it expects data either by separate select lines, or by sending a special command to this slave. after performing all necessary initializations of the ssc, the serial interfaces can be enabled. for a master device, the alternate clock line will now go to its programmed polarity. the alternate data line will go to either '0' or '1', until the first transfer will start. after a transfer the alternate data line will always remain at the logic level of the last transmitted data bit. when the serial interfaces are enabled, the master device can initiate the first data transfer by writing the transmit data into register ssctb. this value is copied into the shift register (which is assumed to be empty at this time), and the selected first bit of the transmit data will be placed onto the mtsr line on the next clock from the baudrate generator (transmission only starts, if sscen=?1?). depending on the selected clock phase, also a clock pulse will be generated on the sclk line. with the opposite clock edge the master at the same time latches and shifts in the data detected at its input line mrst. this ?exchanges? the transmit data with the receive data. since the clock line is connected to all slaves, their shift registers will be shifted synchronously with the master's shift register, shifting out the data contained in the registers, and shifting in the data detected at the input line. after the preprogrammed number of clock pulses (via the data width selection) the data transmitted by the master is contained in all slaves? shift registers, while the master's shift register holds the data of the selected slave. in the master and all slaves the content of the shift register is copied into the receive buffer sscrb and the receive interrupt flag sscrir is set. a slave device will immediately output the selected first bit (msb or lsb of the transfer data) at pin mrst, when the content of the transmit buffer is copied into the slave's shift register. it will not wait for the next clock from the baudrate generator, as the master does. the reason for this is that, depending on the selected clock phase, the first clock edge generated by the master may be already used to clock in the first data bit. so the slave's first data bit must already be valid at this time. note: on the ssc always a transmission and a reception takes place at the same time, regardless whether valid data has been transmitted or received. this is different eg. from asynchronous reception on asc. the initialization of the sclk pin on the master requires some attention in order to avoid undesired clock transitions, which may disturb the other receivers. the state of the internal alternate output lines is '1' as long as the ssc is disabled. this alternate output signal is anded with the respective port line output latch. enabling the ssc with an idle- low clock (sscpo=?0?) will drive the alternate data output and (via the and) the port pin sclk immediately low. to avoid this, use the following sequence:  select the clock idle level (sscpo=?x?)  load the port output latch with the desired clock idle level (p3.13=?x?)  switch the pin to output (dp3.13=?1?)
c165h high-speed synchronous serial interface data sheet 298 2001-04-19 p r e l i m i n a r y - exc er p t -  enable the ssc (sscen=?1?)  if sscpo=?0?: enable alternate data output (p3.13=?1?) the same mechanism as for selecting a slave for transmission (separate select lines or special commands) may also be used to move the role of the master to another device in the network. in this case the previous master and the future master (previous slave) will have to toggle their operating mode (sscms) and the direction of their port pins (see description above). 13.2 half duplex operation in a half duplex configuration only one data line is necessary for both receiving and transmitting of data. the data exchange line is connected to both pins mtsr and mrst of each device, the clock line is connected to the sclk pin. the master device controls the data transfer by generating the shift clock, while the slave devices receive it. due to the fact that all transmit and receive pins are connected to the one data exchange line, serial data may be moved between arbitrary stations. similar to full duplex mode there are two ways to avoid collisions on the data exchange line:  only the transmitting device may enable its transmit pin driver  the non-transmitting devices use open drain output and only send ones. since the data inputs and outputs are connected together, a transmitting device will clock in its own data at the input pin (mrst for a master device, mtsr for a slave). by these means any corruptions on the common data exchange line are detected, where the received data is not equal to the transmitted data.
c165h high-speed synchronous serial interface data sheet 299 2001-04-19 p r e l i m i n a r y - exc er pt - figure 100 ssc half duplex configuration continuous transfers when the transmit interrupt request flag is set, it indicates that the transmit buffer ssctb is empty and ready to be loaded with the next transmit data. if ssctb has been reloaded by the time the current transmission is finished, the data is immediately transferred to the shift register and the next transmission will start without any additional delay. on the data line there is no gap between the two successive frames. eg. two byte transfers would look the same as one word transfer. this feature can be used to interface with devices which can operate with or require more than 16 data bits per transfer. it is just a matter of software, how long a total data frame length can be. this option can also be used eg. to interface to byte-wide and word-wide devices on the same serial bus. note: of course, this can only happen in multiples of the selected basic data width, since it would require disabling/enabling of the ssc to reprogram the basic data width on-the-fly. mcs01965 common transmit/ receive line mrst sclk device #2 slave clock shift register mtsr clock master device #1 clock mtsr mrst sclk shift register shift register clock slave device #3 sclk mtsr mrst
c165h high-speed synchronous serial interface data sheet 300 2001-04-19 p r e l i m i n a r y - exc er p t - port control the ssc uses three pins of port 3 to communicate with the external world. pin p3.13/ sclk serves as the clock line, while pins p3.8/mrst (master receive / slave transmit) and p3.9/mtsr (master transmit / slave receive) serve as the serial data input/output lines. the operation of these pins depends on the selected operating mode (master or slave). in order to enable the alternate output functions of these pins instead of the general purpose i/o operation, the respective port latches have to be set to '1', since the port latch outputs and the alternate output lines are anded. when an alternate data output line is not used (function disabled), it is held at a high level, allowing i/o operations via the port latch. the direction of the port lines depends on the operating mode. the ssc will automatically use the correct alternate input or output line of the ports when switching modes. the direction of the pins, however, must be programmed by the user, as shown in the tables. using the open drain output feature helps to avoid bus contention problems and reduces the need for hardwired hand-shaking or slave select lines. in this case it is not always necessary to switch the direction of a port pin. the table below summarizes the required values for the different modes and pins. note: in the table above, an 'x' means that the actual value is irrelevant in the respective mode, however, it is recommended to set these bits to '1', so they are already in the correct state when switching between master and slave mode. 13.3 baud rate generation the serial channel ssc has its own dedicated 16-bit baud rate generator with 16-bit reload capability, allowing baud rate generation independent from the timers. the baud rate generator is clocked with the cpu clock divided by 2 (f cpu /2). the timer is counting downwards and can be started or stopped through the global enable bit sscen in register ssccon. register sscbr is the dual-function baud rate generator/reload register. reading sscbr, while the ssc is enabled, returns the content of the timer. reading sscbr, while the ssc is disabled, returns the ssc port control pin master mode slave mode function port latch direction function port latch direction sclk serial clock output p3.13 = ? 1 ? dp3.13= ? 1 ? serial clock input p3.13 = ? x ? dp3.13= ? 0 ? mtsr serial data output p3.9 = ? 1 ? dp3.9 = ? 1 ? serial data input p3.9 = ? x ? dp3.9 = ? 0 ? mrst serial data input p3.8 = ? x ? dp3.8 = ? 0 ? serial data output p3.8 = ? 1 ? dp3.8 = ? 1 ?
c165h high-speed synchronous serial interface data sheet 301 2001-04-19 p r e l i m i n a r y - exc er pt - programmed reload value. in this mode the desired reload value can be written to sscbr. note: never write to sscbr, while the ssc is enabled. the formulas below calculate either the resulting baud rate for a given reload value, or the required reload value for a given baudrate: represents the content of the reload register, taken as unsigned 16-bit integer. the maximum baud rate that can be achieved when using a cpu clock of 36 mhz is 18 mbaud in ssc master mode (= ?0 d ?), while in ssc slave mode the maximum baud rate is 9 mbaud (= ?1 d ? since =?0 d ? is not allowed in slave mode). the minimum baud rate is 274.66 baud ( = ?ffff h ? = ?65535 d ?). 13.4 error detection mechanisms the ssc is able to detect four different error conditions. receive error and phase error are detected in all modes, while transmit error and baudrate error only apply to slave mode. when an error is detected, the respective error flag is set. when the corresponding error enable bit is set, also an error interrupt request will be generated by setting ssceir (see figure below). the error interrupt handler may then check the error flags to determine the cause of the error interrupt. the error flags are not reset automatically (like ssceir), but rather must be cleared by software after servicing. this allows servicing of some error conditions via interrupt, while the others may be polled by software. note: the error interrupt handler must clear the associated (enabled) errorflag(s) to prevent repeated interrupt requests. a receive error (master or slave mode) is detected, when a new data frame is completely received, but the previous data was not read out of the receive buffer register sscrb. this condition sets the error flag sscre and, when enabled via sscren, the error interrupt request flag ssceir. the old data in the receive buffer sscrb will be overwritten with the new value and is unretrievably lost. a phase error (master or slave mode) is detected, when the incoming data at pin mrst (master mode) or mtsr (slave mode), sampled with the same frequency as the cpu clock, changes between one sample before and two samples after the latching edge of the clock signal (see ?clock control?). this condition sets the error flag sscpe and, when enabled via sscpen, the error interrupt request flag ssceir. b ssc = f cpu 2 * ( + 1) sscbr = ( f cpu 2 * baudrate ssc ) - 1
c165h high-speed synchronous serial interface data sheet 302 2001-04-19 p r e l i m i n a r y - exc er p t - a baud rate error (slave mode) is detected, when the incoming clock signal deviates from the programmed baud rate by more than 100%, ie. it either is more than double or less than half the expected baud rate. this condition sets the error flag sscbe and, when enabled via sscben, the error interrupt request flag ssceir. using this error detection capability requires that the slave's baud rate generator is programmed to the same baud rate as the master device. this feature detects false additional, or missing pulses on the clock line (within a certain frame). note: if this error condition occurs and bit sscaren=?1?, an automatic reset of the ssc will be performed in case of this error. this is done to reinitialize the ssc, if too few or too many clock pulses have been detected. a transmit error (slave mode) is detected, when a transfer was initiated by the master (shift clock gets active), but the transmit buffer ssctb of the slave was not updated since the last transfer. this condition sets the error flag sscte and, when enabled via sscten, the error interrupt request flag ssceir. if a transfer starts while the transmit buffer is not updated, the slave will shift out the 'old' contents of the shift register, which normally is the data received during the last transfer. this may lead to the corruption of the data on the transmit/receive line in half-duplex mode (open drain configuration), if this slave is not selected for transmission. this mode requires that slaves not selected for transmission only shift out ones, ie. their transmit buffers must be loaded with 'ffff h ' prior to any transfer. note: a slave with push/pull output drivers, which is not selected for transmission, will normally have its output drivers switched. however, in order to avoid possible conflicts or misinterpretations, it is recommended to always load the slave's transmit buffer prior to any transfer.
c165h high-speed synchronous serial interface data sheet 303 2001-04-19 p r e l i m i n a r y - exc er pt - figure 101 ssc error interrupt control 13.5 ssc interrupt control three bit addressable interrupt control registers are provided for serial channel ssc. register ssctic controls the transmit interrupt, sscric controls the receive interrupt and ssceic controls the error interrupt of serial channel ssc. each interrupt source also has its own dedicated interrupt vector. sctint is the transmit interrupt vector, scrint is the receive interrupt vector, and sceint is the error interrupt vector. the cause of an error interrupt request (receive, phase, baudrate,transmit error) can be identified by the error status flags in control register ssccon. note: in contrary to the error interrupt request flag ssceir, the error status flags sscxe are not reset automatically upon entry into the error interrupt service routine, but must be cleared by software. & sscten sscte transmit error register ssccon & sscren sscre receive error & sscpen sscpe phase error & sscben sscbe baudrate error 1 & ssceie ssceir error interrupt ssceint register ssceic mca01968
c165h high-speed synchronous serial interface data sheet 304 2001-04-19 p r e l i m i n a r y - exc er p t - ssctic (ff72 h / b9 h ) sfr reset value: - - 00 h sscric (ff74 h / ba h ) sfr reset value: - - 00 h ssceic (ff76 h / bb h ) sfr reset value: - - 00 h note: please refer to the general interrupt control register description on page 99 for an explanation of the control fields. ssc tie ssc tir 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw - - - - rw rw - - - - glvl ilvl ssc rie ssc rir 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw - - - - rw rw - - - - glvl ilvl ssc eir ssc eie 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw - - - - rw rw - - - - glvl ilvl
c165h high-speed synchronous serial interface data sheet 305 2001-04-19 p r e l i m i n a r y - exc er pt - ssc clock control register sscclc (f0b6 h ) reset value: 0000 h bit function sscdisr ssc disable request bit sscdisr = ? 0 ? : ssc clock disable not requested sscdisr = ? 1 ? : ssc clock disable requested sscdiss ssc disable status bit sscdiss = ? 0 ? : ssc clock enabled sscdiss = ? 1 ? : ssc clock disabled suspen peripheral suspend enable bit for ocds suspen = ? 0 ? : peripheral suspend disabled suspen = ? 1 ? : peripheral suspend enabled exdisr external disable request exrdis = ? 0 ? : external clock disable request is enabled exrdis = ? 1 ? : external clock disable request is disabled 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 ssc disr ssc diss 0 0 0 0 0 0 rw r rw rw 0 0 0 0 0 0 sus pen ex disr
c165h iom-2 interface controller data sheet 306 2001-04-19 p r e l i m i n a r y - exc er p t - 14 iom-2 interface controller the c165h supports the iom-2 interface with single/double bitrate clock in terminal (te) mode, as well as the linecard (lt) and pcm mode. the iom-2 interface consists of four lines: the inputs fsc and dcl as well as the bidirectional pins dd and du. note: in the c165h the bitrate clock (bcl) is driven on the dcl (double bitrate clock) line. in this document the term ?bcl? is used to indicate the single bitrate clock. the rising edge of fsc indicates the start of an iom-2 frame. typically, the fsc signal is generated by the upstream transceiver, which synchronizes to the received framing indication. the dcl input clock signal synchronizes the data transfer on both data lines. for double bitrate clock the bits are shifted out with the rising edge of the first dcl clock cycle and sampled at the falling edge of the second clock cycle. for single bitrate clock the bits are shifted with the rising edge of the bcl and sampled with the falling edge of the bcl. 14.1 iom-2 and pcm frame structure 14.1.1 definitions the following definitions are used throughout the documentaion of the iom-2 interface controller. 14.1.1.1 frame structure the iom-2 frame structure is defined as: 1. a start of a frame is detected by the rising edge of the fsc signal. the length of the fcs signal being high is irrelevant for the iom-2 unit, as long as it comprises with the signal specification. 2. the iom-2 module synchronizes automatically to the frame length (i.e. number of bits/ octets) generated by the dcl signal. 3. the clkm bit of the iom_cr register specifies whether the dcl is a single or double bitrate clock. 4. a frame is always 125 s on iom. 5. a frame always consists of multiple of 8 bit time slots. 6. the iom-2 module does not distinguish between the different frame modes (pcm,te, lt). each frame structure can be configured by specifying the corresponding time slot. table 64 shows a summary of design parameters for different frame structures (e.g.terminal mode, the lincard mode and the pcm mode).
c165h iom-2 interface controller data sheet 307 2001-04-19 p r e l i m i n a r y - exc er pt - 14.1.1.2 hdlc channels on the iom-2: b1, b2, d1, d2 the iom-2 interface controller module contains two 8-bit hdlc channels and two 2-bit hdlc channels (bit 0 and 1 of an octet). these channels can be configured to any of the 32 iom-2 time slots. the main use for these hdlc channels is: b1 and b2 for the 8-bit channels and d1 and d2 for the 2-bit channels. therefore the terms b1, b2, d1, and d2 are used throughout this document. 14.1.2 pcm mode the frame structure in pcm mode consists of 1..32 individual octets. this is a bit rate of 64..2048 kbit/s in steps of 64 kbit/s. all the iom-2 channels (e.g. b1, b2, d1, d2, cda) can be individually mapped to any of the 32 timeslots. therefor any other frame mode type can be configured. note: there is no protection or checking for exclusive use of one timeslot by different iom-2 channels. this must be insured by the sw. 14.1.3 terminal mode the frame structure on the iom-2 data ports (du,dd) in iom-2 terminal mode is shown in figure 102 . table 64 iom-2 parameters for different modes (te, lt, pcm) min max te mode lt mode pcm mode octets per fsc 1 32 12 n 4, n { 1,2,3,..,8 } m { 1,2,3,..,32 } number of bits per fsc 8 256 96 n 4 8, n { 1,2,3,..,8 } m 8, m { 1,2,3,..,32 } fsc clock rate 8 khz 8 khz 8 khz 8 khz 8 khz bcl clock rate (fsc bits) 64 khz 2048 khz 768 khz n 256 khz, n { 1,2,3,..,8 } m 64 khz, m { 1,2,3,..,32 } dcl clock rate (2 bcl) 128 khz 4096 khz 1536 khz n 512 khz, n { 1,2,3,..,8 } m 128 khz, m { 1,2,3,..,32 }
c165h iom-2 interface controller data sheet 308 2001-04-19 p r e l i m i n a r y - exc er p t - figure 102 iom ? -2 frame structure in terminal mode the frame is composed of three channels  channel 0 contains 144-kbit/s of user and signaling data (2b + d1), an optional monitor programming channel (mon0) and an optional command/indication channel (ci0) for control and programming of a layer-1 transceiver, if any.  channel 1 contains two 64-kbit/s intercommunication channels (ic) plus a monitor and command/indicate channel (mon1, ci1) to program or transfer data to other iom- 2 devices.  channel 1 provides acces to an optional second signaling channel d2 in ci1(7:6)  channel 2 can be used for the tlc-bus access. additionally channel 2 supports further ic and mon channels. note: each octet related to any integrated functional block can be programmed to any of the 12 timeslots. exceptions are the c/i0-channel, which is always related to channel 0 (i.e. timeslot 3), c/1-channel, which is always related to channel 1 (i.e. timeslot 7). the monitor channel can be configured to one of 3 iom channels in tm mode (timeslot 2, 6 or 10) or one of 8 iom channels in lt mode (timeslot 2, 6, 10, 14, 18, 22, 26 or 30).
c165h iom-2 interface controller data sheet 309 2001-04-19 p r e l i m i n a r y - exc er pt - 14.1.4 linecard mode the frame structure on the iom-2 data ports (du,dd) in iom-2 linecard mode is shown in figure 103 . figure 103 iom ? -2 frame structure in linecard mode the frame is composed of up to eight iom channels (see also tm mode). 14.2 iom-2 handler the iom-2 handler offers a great flexibility for handling the data transfer between the different functional units of the c165h and voice/data devices connected to the iom-2 interface. additionally it provides direct cpu access to all time slots of the iom-2 interface via the four controller data access registers (cda). figure 104 shows the architecture of the iom-2 handler. for illustrating the functional description it contains all configuration and control registers of the iom-2 handler. the controller data access (cda) can be configured by programming the time slot and data port selection registers (tsdp). with the tss bits (time slot selection) the data of the functional units can be assigned to the available time slots of the iom-2 frame. with the dps bit (data port selection) the output of each functional unit is assigned to either du or dd line respectively. the input is assigned vice versa. with the control registers (cr) the access to the data of the functional units can be controlled by setting the itd09635 ch1 ch2 ch3 ch4 ch5 ch6 ch7 ch0 ch0 ch7 ch6 ch5 ch4 ch3 ch2 ch1 b1 b2 monitor d c/i mm rx 125 fsc dcl dd du s iom ch0 iom ch0 r r
c165h iom-2 interface controller data sheet 310 2001-04-19 p r e l i m i n a r y - exc er p t - corresponding control bits (en, swap), see chapter 14.5, "controller data access handler". the iom-2 handler provides also access to the  monitor channel (mon)  command indication (c/i) channels (ci0,ci1)  tic bus (tic)  two 8-bit hdlc data channels (b1, b2)  two 2-bit hdlc data channels (d1, d2) the access to these channels is controlled by the registers mon_cr, cic_cr, iomsel_x. the iom-2 interface is controlled by the control register iom_cr. . figure 104 architecture of the iom-2 handler iom-2 interface control data access (tsdp, dps, en, swap, mcda, sti) mon tic data microcontroller interface iomhand.drw du dd du dd fsc dcl iom-2 handler ci0 ci1 control monitor data (dps,en mcs) mon_cr iom_cr (en, od) du dd x,y = 1 or 2 cda register cda10 controller data access (cda) handler cda_tsdpxy cda_crx mcda sti msti asti cda11 cda20 cda21 tic bus disable control ci1 data (dps,en) hdlc-0 fifo hdlc-1 fifo hdlc-2 fifo hdlc-3 fifo dps, en, tss monitor data tic bus data ci0 data ci1 data d1/d2/b1/b2 data d1/d2/b1/b2 data d1/d2/b1/b2 data d1/d2/b1/b2 data cda data control ci0 data (dps, en) cic_cr
c165h iom-2 interface controller data sheet 311 2001-04-19 p r e l i m i n a r y - exc er pt - 14.3 iom-2 monitor handler the iom-2 monitor channel is utilized for information exchange between the c165h and other devices connected to the monitor channel. the monitor channel data can be controlled by the bits in the monitor control register (mon_cr). for the monitor data one of the up to 3 (te) or up to 8 (lt/pcm) iom channels can be selected by setting the monitor channel selection bits (mcs). the dps bit in the same register selects between an output on du or dd respectively and with en_mon the monitor functionlity can be enabled/disabled. the default value is monitor channel 0 (mon0) enabled and transmisson on dd. the following applications may apply.  the c165h can program and control other devices attached to the iom-2 which do not need a microcontroller interface.  for data exchange between two microcontroller systems attached to two different devices on one iom-2 backplane. use of the monitor channel avoids the necessity of a dedicated serial communication path between the two systems. this simplifies the system design. 14.3.1 handshake procedure the monitor channel operates on an asynchronous basis. while data transfers on the bus take place synchronized to frame sync, the flow of data is controlled by a handshake procedure using the monitor channel receive (mr) and monitor channel transmit (mx) bits. data is placed onto the monitor channel and the mx bit is activated (mx =?0?). this data will be transmitted once per 8-khz frame until the transfer is acknowledged via the mr bit (mr=?0?). the monitor channel protocol between a transmitter c ( ct) and a receiver c ( cr) is described in the following section and illustrated in figure 105 . the relevant control and status bits for transmission and reception are listed in table 65 and table 66 . table 65 transmission of monitor data control/ status bit register bit function control mocr mxc mx bit control mie mda and mab interrupt enable status mosr mda data acknowledged interrupt mab data abort interrupt msta mac transmission active
c165h iom-2 interface controller data sheet 312 2001-04-19 p r e l i m i n a r y - exc er p t - table 66 reception of monitor data control/ status bit register bit function control mocr mrc mr bit control mie mer interrupt enable mre mdr interrupt enable status mosr mdr data received interrupt mer end of reception interrupt
c165h iom-2 interface controller data sheet 313 2001-04-19 p r e l i m i n a r y - exc er pt - figure 105 monitor channel protocol (iom-2) transmission c ( ct ) mie=1 mox=adr mxc=1 mac=1 mda int. mox=data1 mda int. mox=data2 mda int. mxc=0 mac=0 mon ff ff adr data1 data2 adr data1 data2 ff ff mx data1 data1 data2 data2 ff ff 1 1 0 0 1 0 0 0 1 0 0 0 1 1 1 1 mr 1 1 1 0 0 0 1 0 0 0 1 0 0 0 1 1 reception c ( cr ) 125s mdr int. rd mor (=adr) mrc=1 mer int. mrc=0 mdr int. rd mor (=data2) rd mor (=data1) mdr int. adr 0 1 adr 00 mre=1 mie=1
c165h iom-2 interface controller data sheet 314 2001-04-19 p r e l i m i n a r y - exc er p t - before starting a transmission, the ct should verify that the transmitter is inactive, i.e. that a possible previous transmission has been terminated. this is indicated by a ?0? in the monitor channel active mac status bit. after having written the monitor data transmit (mox) register, the ct sets the monitor transmit control bit mxc to ?1?. this enables the mx bit to go active (0), indicating the presence of valid monitor data (contents of mox) in the corresponding frame. as a result, the receiving device stores the monitor byte in its monitor receive mor register and generates an mdr interrupt status (mre must be ?1?). alerted by the mdr interrupt, the cr reads the monitor receive (mor) register. when it is ready to accept data (e.g. based on the value in mor, which in a point-to- multipoint application might be the address of the destination device), it sets the mr control bit mrc to ?1? to enable the receiver to store succeeding monitor channel bytes and acknowledge them according to the monitor channel protocol. in addition, it enables other monitor channel interrupts by setting monitor interrupt enable (mie) to ?1?. as a result, the first monitor byte is acknowledged by the receiving device setting the mr bit to ?0?. this causes a monitor data acknowledge mda interrupt status at the transmitter. a new monitor data byte can now be written by the ct in mox. the mx bit is still in the active (0) state. the transmitter indicates a new byte in the monitor channel by returning the mx bit active after sending one frame in the inactive state. as a result, the receiver stores the monitor byte in mor and generates a new mdr interrupt status. when the cr has read the mor register, the receiver acknowledges the data by returning the mr bit active after sending one frame in the inactive state. this in turn causes the transmitter to generate an mda interrupt status. this "mda interrupt ? write data ? mdr interrupt ? read data ? mda interrupt" handshake is repeated as long as the transmitter has data to send. when the last byte has been acknowledged by the receiver (mda interrupt status), the microcontroller sets the monitor transmit control bit mxc to ?0?. this enforces an inactive (?1?) state in the mx bit. two frames of mx inactive signifies the end of a message. thus, a monitor channel end of reception mer interrupt status is generated by the receiver when the mx bit is received in the inactive state in two consecutive frames. as a result, the microcontroller sets the mr control bit mrc to 0, which in turn enforces an inactive state in the mr bit. this marks the end of the transmission, making the monitor channel active mac bit return to ?0?. the monitor transfer protocol rules are summarized in the following section  a pair of mx and mr in the inactive state for two or more consecutive frames indicates an idle state or an end of transmission . a start of a transmission is initiated by the transmitter by setting the mxc bit to ?1? enabling the internal mx control. the receiver acknowledges the received first byte by setting the mr control bit to ?1? enabling the internal mr control.
c165h iom-2 interface controller data sheet 315 2001-04-19 p r e l i m i n a r y - exc er pt -  the internal mx,mr control indicates or acknowledges a new byte in the mon slot by toggling mx,mr from the active to the inactive state for one frame.  two frames with the mx-bit in the inactive state indicate the end of transmission .  two frames with the mr-bit set to inactive indicate a receiver request for abort (see chapter 14.3.2).  the transmitter can delay a transmission sequence by sending the same byte continuously. in that case the mx-bit remains active in the iom-2 frame following the first byte occurrence. since a double last-look criterion is implemented the receiver is able to receive the mon slot data at least twice (in two consecutive frames). the receiver acknowledge the data after the reception of two identical bytes in two successive frames.  to control this handshake procedure a collision detection mechanism is implemented in the transmitter. this is done by making a collision check per bit on the transmitted monitor data and the mx bit.  monitor data will be transmitted repeatedly until its reception is acknowledged or the transmission time-out timer expires.  two frames with the mx bit in the inactive state indicates the end of a message (eom).  monitor control commands are processed sequential that means e.g. during a read on a register no further command is executed. 14.3.2 abort procedure during a transmission process, it is possible for the receiver to ask a transmission to be aborted by sending an inactive mr bit value in two consecutive frames. this is effected by the microcontroller writing the mr control bit mrc to ?0?. an aborted transmission is indicated by a monitor channel data abort mab interrupt status at the transmitter. the mx/mr bits are under control of the microcontroller through mxc or mrc respectively. an abort is indicated by an mab interrupt or mer interrupt respectively. a transmission is aborted by the c165h if  abort request from receiver is detected (see figure 106 )  a collision on the iom bus of the monitor data or mx bit occurs  a recommended software timer (gpt) expires a reception is aborted by the c165h if  an abort request from the transmitting device occurs, see figure 107 . this abort request has basically the same waveform as an end of transmission, see figure 108 . note: in case the c165h does not detect identical monitor messages in two successive frames, transmission is not aborted. instead the c165h will wait until two identical bytes are received in succession.
c165h iom-2 interface controller data sheet 316 2001-04-19 p r e l i m i n a r y - exc er p t - figure 106 monitor channel, transmission abort requested by the receiver figure 107 monitor channel, transmission abort requested by the transmitter mx (du) iom -2 frame no. 1 2 345 67 eom mr (dd) 1 0 1 0 mon_rec-abort.vsd abort request from receiver mr (du) iom -2 frame no. 1 2 345 67 mx (dd) 1 0 1 0 eom mon_tx-abort.vsd abort request from transmitter
c165h iom-2 interface controller data sheet 317 2001-04-19 p r e l i m i n a r y - exc er pt - figure 108 monitor channel, normal end of transmission note: the monitor time-out register bit, known from other infineon devices, is not implemented within the c165h. to prevent lock-up situations in a monitor transmission, a gpt timer can be programmed accordingly. 14.3.3 monitor interrupt logic figure 109 shows the monitor interrupt structure of the c165h. the monitor data receive interrupt status mdr has two enable bits, monitor receive interrupt enable ( mre ) and mr bit control ( mrc ). the monitor channel end of reception mer , monitor channel data acknowledged mda and monitor channel data abort mab interrupt status bits have a common enable bit monitor interrupt enable mie . mre inactive (0) prevents the occurrence of mdr status, including when the first byte of a packet is received. when mre is active (1) but mrc is inactive, the mdr interrupt status is generated only for the first byte of a receive packet. when both mre and mrc are active, mdr is always generated and all received monitor bytes - marked by a 1- to-0 transition in mx bit - are stored. (additionally, an active mrc enables the control of the mr handshake bit according to the monitor channel protocol.) mr (du) iom -2 frame no. 1 2 345 67 mx (dd) 1 0 1 0 eom mon_norm.vsd 8
c165h iom-2 interface controller data sheet 318 2001-04-19 p r e l i m i n a r y - exc er p t - figure 109 monitor interrupt structure 14.4 c/i channel handler the command/indication channel carries real-time status information between the c165h and another device connected to the iom. 14.4.1 c/i0 - command/indication 0 one c/i channel (called c/i0) conveys the commands and indications between the c165h and an external layer-1 device. c/i0 channel access may be arbitrated via the tic bus access protocol. in this case the arbitration is done in c/i channel 2 (timeslot 1), see figure 102 . the c/i0 channel is accessed via register bit cic0_d.codr0 (in receive direction, layer- 1 to layer-2) and register cic0_d.codx0 (in transmit direction, layer-2 to layer-1). the c/i0 code is four bits long. in the receive direction, the code from layer-1 is continuously monitored, with an interrupt being generated anytime a change occurs (ista.cic). a new code must be found in two consecutive iom frames to be considered valid and to trigger a c/i code change interrupt status (double last look criterion). in the transmit direction, the code written in cix0 is continuously transmitted in c/i0. 14.4.2 c/i1 - command/indication 1 a second c/i channel (called c/i1) can be used to convey real time status information between the c165h and various non-layer-1 peripheral devices. the c/i1 channel consists of four or six bits in each direction.the width can be changed from 4bit to 6bit by setting bit cic_cmd.cicw. the c/i1 channel is accessed via registers cic1_d.codr1 and cic1_d.codx1. a change in the received c/i1 code is indicated by an interrupt status without double last look criterion. cic st mos hdlc iomint ista mask cic st mos mre mdr mie mda mer mab mosr mocr 4x hdlc 4x
c165h iom-2 interface controller data sheet 319 2001-04-19 p r e l i m i n a r y - exc er pt - note: the function of the c/i1 channel change detection (cic_st.ci1) gets disabled when disabling the according interrupt (cic_cmd.ci1e set to ?0?). 14.4.3 cic interrupt logic figure 110 shows the cic interrupt structure. a cic interrupt may originate  from a change in received c/i channel 0 code (cic0_d.codr_0) or  from a change in received c/i channel 1 code (cic1_d.codr_1). the two corresponding status bits cic0 and cic1 are in cic_st register. cic1 can be individually disabled by clearing the enable bit ci1e in the cix1 register. in this case the occurrence of a code change in cir1 will not be displayed by cic1 until the corresponding enable bit has been set to one. bits cic0 and cic1 are cleared by writing ?1? into the specific bit. an interrupt status is issued every time a valid new code is loaded into cir0 or cir1. the cir0 is buffered with a fifo size of two. if a second code change occurs in the received c/i channel 0 before the first one has been read, immediately after reading of cir0 a new interrupt will be generated and the new code will be stored in cir0. if several consecutive codes are detected, only the first and the last code is obtained at the first and second register read, respectively. for cir1 no buffering is available. the actual code of the received c/i channel 1 is always stored in cir1. figure 110 cic interrupt structure 14.4.4 d-channel access control d-channel access control is defined to guarantee all connected hdlc controllers a fair chance to transmit data in the d-channel. collisions are possible on the iom-2 interface, cic st mos hdlc iomint ista mask cic1 ci1e cic0 cir0 cix1 cic st mos 4x hdlc 4x
c165h iom-2 interface controller data sheet 320 2001-04-19 p r e l i m i n a r y - exc er p t - if there is more than one hdlc controller connected. this arbitration mechanism is implemented in the c165h and will be described in the following chapter. note: d-channel access control is only necessary if several d-channel controllers try to access the same space on the iom-2 bus. note: the tic bus d-channel access control mechanism, as described in chapter 14.4.4.1, is implemented for hdlc-2 controller only. 14.4.4.1 tic bus d-channel access control for hdlc-2 controller the tic bus is implemented to organize the access to the layer-1 functions of the transceiver device via iom-2 interface (c/i-channel) and to the d-channel from up to 7 external communication controllers. the arbitration mechanism is implemented in the last octet in iom channel 2 of the iom-2 interface (iom-2 te mode only, tic_dis in iom_cr is disabled). an access request to the tic bus may either be generated by software (mp access to the c/i channel) or by the c165h itself (transmission of an hdlc frame in the d-channel). a software access request to the bus is effected by setting the bac bit (cic_cmd register) to ?1?. in the case of an access request, the c165h checks the bus accessed-bit bac (bit 5 of du last octet of channel 2) for the status "bus free?, which is indicated by a logical ?1?. if the bus is free, the c165h transmits its individual tic bus address tad programmed in the cic_cmd register and compares it bit by bit with the value on du. if a sent bit set to ?1? is read back as ?0? because of the access of another d-channel source with a lower tad, the c165h withdraws immediately from the tic bus. the tic bus is occupied by the device which sends its address error-free. if more than one device attempt to seize the bus simultaneously, the one with the lowest address wins and starts d-channel transmission. figure 111 structure of last octet of ch2 on du du tic_octet-du.vsd b1 b2 mon0 ic1 ic2 mon1 ci1 ci0 d bac tad mx mr mx mr bac tad 20 1 tic-bus address (tad 2-0) bus accessed ('1' no tic-bus access)
c165h iom-2 interface controller data sheet 321 2001-04-19 p r e l i m i n a r y - exc er pt - when the tic bus is seized by the c165h, the bus is identified to other devices as occupied via the du channel 2 bus accessed-bit state ?0? until the access request is withdrawn. after a successful bus access, the c165h is automatically set into a lower priority class, that is, a new bus access cannot be performed until the status "bus free" is indicated in two successive frames. if none of the devices connected to the iom interface requests access to the d channel, the tic bus address 7 will be present. the device with this address will therefore have access, by default, to the d channels. note: bit bac (cic_cmd register) should be reset by the p when access to the c/i channels is no more requested, to grant other devices access to the d and c/i channels. the availability of the line interface d channel is indicated in bit 5 "s/g" (s/g) of the dd last octet of channel 2. s/g = 1: stop s/g = 0: go after the bac bit has been set to active and the c165h has achieved the lowest tad, the s/g bit is checked in order to avoid collision with external layer 1 devices sending on the d-channel. figure 112 structure of last octet of ch2 on dd 14.5 controller data access handler the c165h iom-2 handler provides with his four controller data access registers (cda10, cda11, cda20, cda21) a very flexible solution for the access to any possible timeslot. the functional unit cda (controller data access) allows with its control and configuration registers dd tic_octet-du.vsd b1 b2 mon0 ic1 ic2 mon1 ci1 ci0 d mx mr mx mr s/g stop/go ee s/g
c165h iom-2 interface controller data sheet 322 2001-04-19 p r e l i m i n a r y - exc er p t -  looping of up to four independent iom-2 interface channels from du to dd or vice versa over the four cda registers  shifting or switching of two independent iom-2 interface channels to another two independent iom-2 interface channels on both data ports (du, dd)  monitoring of up to four time slots on the iom-2 interface simultaneously  microcontroller read and write access to each iom-2 interface channel 14.5.1 description the access principle which is identical for the two channel register pairs cda10/11 and cda20/21 is illustrated in figure 113 . the index variables x,y used in the following description can be 1 or 2 for x, and 0 or 1 for y. the prefix ?cda_? from the register names has been omitted for simplification. to each of the four cdaxy data registers a tsdpxy register is assigned which specifies the time slot and the data port. with the tss (time slot selection) bits a time slot from 0...31 can be selected. with the dps (data port selection) bit the output of the cdaxy register can be assigned to du or dd respectively. the time slot and data port for the output of cdaxy is always defined by its own tsdpxy register. the input of cdaxy depends on the swap bit in the control registers cdax_cr. if the swap bit = ?0? the time slot and data port for the input and output of the cdaxy register is defined by its own tsdpxy register. the data port for the cdaxy input is vice versa to the output setting for cdaxy. if the swap bit = ?1?, the input port and time slot of the cdax0 is defined by the tsdp register of cdax1 and the input port and time slot of cdax1 is defined by the tsdp register of cdax0. the input and output of every cdaxy register can be enabled or disabled by setting the corresponding en (-able) bit in the control register cdax_cr. if the input of a register is disabled the output value in the register is retained.
c165h iom-2 interface controller data sheet 323 2001-04-19 p r e l i m i n a r y - exc er pt - . figure 113 data access via cdax0 and cdax1 register pairs 14.5.2 looping and shifting data figure 114 gives examples for typical configurations with the above explained control and configuration possibilities with the bits tss, dps, en and swap in the registers tsdpxy or cdax_cr: a) looping iom-2 time slot data from du to dd or vice versa (swap = ?0?) b) shifting data from tsa to tsb on du and dd (swap = ?1?) c) switching data from tsa (du) to tsb(dd) and tsb (du) to tsa (dd) du cdax1 control register cda_crx dd 1 1 time slot selection (tss) input swap (swap) 1 x = 1 or 2; a,b = 0...11 data port cda_tsdpx1 0 1 0 1 iom_hand.fm4 1 0 1 1 enable input (en_o0) output cda_tsdpx0 1 0 cdax0 1 (en_i0) (en_i1) input enable output (en_o1) selection (dps) data port selection (dps) selection (tss) time slot tsa tsa tsb tsb
c165h iom-2 interface controller data sheet 324 2001-04-19 p r e l i m i n a r y - exc er p t - figure 114 examples for data access via cdaxy registers a) looping data b) shifting data c) switching data tsa tsb cdax0 tsa tsb du dd tsa tsb du dd b) shifting data a) looping data .tss: .dps .swap ? 0 ? ? 1 ? ? 0 ? tsa tsb .tss: .dps .swap ? 1 ? ? 1 ? ? 0 ? tsa tsb du dd c) switching data tsa tsb .tss: .dps .swap ? 1 ? ? 0 ? ? 0 ? .x = 1 or 2 cdax0 cdax0 cdax0 cdax0 cdax0
c165h iom-2 interface controller data sheet 325 2001-04-19 p r e l i m i n a r y - exc er pt - 14.5.3 monitoring data figure 115 gives an example for monitoring of two iom-2 time slots each on du or dd simultaneously. . figure 115 example for monitoring data note: due to the hardware design, there are some restrictions for the cda monitoring data function. these restrictions apply if the cda monitoring function is used to monitor other active functions (e.g. b1, b2, d1, d2, tic, cic, monitor). these restrictions do not apply if the dps setting of the monitoring cda channel and the active channel are different. if the dps setting of the monitoring cda channel is equal to the dps setting of the monitored active channel, following rules apply:  in case of monitoring b1, monitor, tic the data is stored in the specified cda_xy register (normal function).  in case of monitoring b2, d1, d2, cic the data is stored in the reverse cda_xy register. for example, when activating cda_10, it is stored in cda_11 and if cda_11 activated, it is stored in cda_10. cda10 cda11 cda20 cda21 ts(2n) ts(2m+1) du dd a) monitoring data tss: ts(2n) ts(2m+1) tss: ? 1 ? ? 1 ? dps: ? 0 ? ? 0 ? dps: ? 0 ? ? 0 ? en_o: ? 1 ? ? 1 ? en_i: ? 0 ? ? 0 ? en_o: ? 1 ? ? 1 ? en_i: cda_cr1. cda_cr2. n,m = 0...5
c165h iom-2 interface controller data sheet 326 2001-04-19 p r e l i m i n a r y - exc er p t - 14.5.4 synchronous transfer while looping, shifting and switching the data can be accessed by the controller between the synchronous transfer interrupt (sti) and the status overflow interrupt (stov). the microcontroller access to the cdaxy registers can be synchronized by means of four programmable synchronous transfer interrupts (stixy) and synchronous transfer overflow interrupts (stovxy) in the sti register. depending on the dps bit in the corresponding cda_tsdpxy register the stixy is generated two (for dps=?0?) or one (for dps=?1?) bcl clock after the selected time slot (cda_tsdpxy.tss). one bcl clock is equivalent to two dcl clocks. a non masked synchronous transfer overflow (stovx 0 y 0 ) interrupt is generated if the appropriate stix 1 y 1 is not acknowledged in time. the stix 1 y 1 is acknowledged in time if bit ackx 1 y 1 in the asti register is set to ?1? one bcl clock (for dps=?0?) or zero bcl clocks (for dps=?1?) before the time slot which is selected for the appropriate stovx 0 y 0 . if stix 1 y 1 and stovx 1 y 1 are not masked stovx 1 y 1 is only related to stix 1 y 1 ( see example a), c) and d) of figure 117 ). if stix 1 y 1 is masked but stovx 1 y 1 is not masked, stovx 0 y 0 is related to each enabled stixy ( see example b) and d) of figure 117 ). setting the corresponding bits in the msti (mask synchronous transfer interrupts) register masks the stixy and the stovxy interrupt. the interrupt structure of the synchronous transfer is shown in figure 116 . examples of the described synchronous transfer interrupt controlling are illustrated in figure 117 . a read to the sti register clears the stixy and stovxy interrupts. . figure 116 interrupt structure of the synchronous data transfer cic st mos hdlc hdlc cic st mos iomint sti11 ista mask msti sti sti10 sti20 sti21 stov10 stov11 stov20 stov21 sti11 sti10 sti20 sti21 stov10 stov11 stov20 stov21 ack11 asti ack10 ack20 ack21 4x 4x
c165h iom-2 interface controller data sheet 327 2001-04-19 p r e l i m i n a r y - exc er pt - . figure 117 examples for the synchronous transfer interrupt control with one enabled stixy figure 118 shows the timing of looping tsa on du to tsa on dd (a = 0...11) via cdaxy register. tsa is read in the cdaxy register from du and is written one frame later on dd. xy: 10 11 21 20 cda_tdspxy.tss: ts0 ts1 ts5 ts11 msti.stixy: '0' '1' '1' '1' msti.stovxy: '0' '1' '1' '1' ts7 ts5 ts6 ts4 ts3 ts1 ts2 ts0 ts11 ts9 ts10 ts8 ts0 ts11 a) interrupts for data access to time slot 0 (b1 after reset), msti.sti10 and msti.stov10 enabled xy: 10 11 21 20 cda_tdspxy.tss: ts0 ts1 ts5 ts11 msti.stixy: '0' '1' '1' '1' msti.stovxy: '1' '1' '1' '0' ts7 ts5 ts6 ts4 ts3 ts1 ts2 ts0 ts11 ts9 ts10 ts8 ts0 ts11 b) interrupts for data access to time slot 0 (b1 after reset), stov interrupt used as flag for "last possible cda access"; msti.sti10 and msti.stov20 enabled c) interrupts for data access to time slot 0 and 1 (b1 and b2 after reset), msti.sti10, msti.stov10, msti.sti11 and msti.stov11 enabled sti_stov.vsd xy: 10 11 21 20 cda_tdspxy.tss: ts0 ts1 ts5 ts11 msti.stixy: '0' '0' '1' '1' msti.stovxy: '0' '0' '1' '1' ts7 ts5 ts6 ts4 ts3 ts1 ts2 ts0 ts11 ts9 ts10 ts8 ts0 ts11 d) interrupts for data access to time slot 0 (b1 after reset), stov20 interrupt used as flag for "last possible cda access", stov10 interrupt used as flag for "cda access failed"; msti.sti10, msti.stov10 and msti.stov20 enabled xy: 10 11 21 20 cda_tdspxy.tss: ts0 ts1 ts5 ts11 msti.stixy: '0' '1' '1' '1' msti.stovxy: '0' '1' '1' '0' ts7 ts5 ts6 ts4 ts3 ts1 ts2 ts0 ts11 ts9 ts10 ts8 ts0 ts11 : stov interrupt generated for a not acknowledged sti interrupt : sti interrupt generated
c165h iom-2 interface controller data sheet 328 2001-04-19 p r e l i m i n a r y - exc er p t - . figure 118 data access when looping tsa from du to dd figure 119 shows the timing of shifting data from tsa to tsb on du(dd). in figure 119a) shifting is done in one frame because tsa and tsb didn?t succeed direct one another (a,b = 0...9 and b = a+2). in figure 119b) shifting is done from one frame to the following frame. this is the case when the time slots succeed one other (b = a+1) or b is smaller than a (b < a). tsa du tsa fsc cdaxy c rd wr ack stov tsa dd tsa sti a = 0...11 *) if access by the c is required *) sti
c165h iom-2 interface controller data sheet 329 2001-04-19 p r e l i m i n a r y - exc er pt - figure 119 data access when shifting tsa to tsb on du (dd) 14.6 bus activation / deactivation (power down) the iom-2 bus has an activation/deactivation capability. activation and deactivation can be initiated from either the upstream or downstream component on the bus. when deactivated, dcl is held low and the data lines are held high. the activation/deactivation procedure is a combination of software handshakes via the c/i channel, and hardware indications via the clock and data lines. tsa du tsb fsc cdaxy c rd wr ack stov sti tsa sti tsa cdaxy c rd wr ack stov sti tsb tsa tsb (dd) (a,b: 0...11 and (b = a+1 or b c165h iom-2 interface controller data sheet 330 2001-04-19 p r e l i m i n a r y - exc er p t - in this chapter the hardware related parts are described. 14.6.1 deactivation request, downstream (c165h) to upstream there is currently no defined procedure for requesting deactivation from downstream. the deactivation procedure is shown in figure 120 . after detecting the code di (deactive indication) from the downstream unit, the upstream unit responds by transmitting dc (deactive confirmation) during subsequent frames. the upstream unit stops sending timing signals after it has transmitted the last bit of the fourth consecutive dc command. figure 120 deactivation of the iom-2 interface the iom-2 handler contains a dcl clock supervision unit. this unit is a counter which is set to the dcl clock supervision interval (dcsi) at each rising edge of the dcl clock and counts down with each xbus clock. once the counter reaches ?0?, it remains at this value. if the counter is ?0?, the bit cic_st.dcod is set to ?1?, otherwise cic_st.dcod is set to ?0?. any change in cic_st.dcod results in setting the ista.dcsi interrupt. itd09655 diu did dr fsc du dd deactivated d b2 mono d b1 cio cio dcl r iom -2 iom -2 r diu diu diu diu diu diu diu diu dr dr dr dr did did did
c165h iom-2 interface controller data sheet 331 2001-04-19 p r e l i m i n a r y - exc er pt - note: the dcsi must be set in relation to the dcl frequency and the actual xbus frequency. if the dcl clock is active, the dcl clock supervision counter should not be able to count downto zero before the next rising edge of the dcl clock. at the detection of the ista.dcsi interrupt and cic_st.dcod being ?1? (this indicates the dcl clock has been switched off by the upstream device) the cpu of the c165h can deactivate the iom-2 module. 14.6.2 deactivation, upstream to downstream (c165h) the upstream unit can initiate deactivation via a series of software handshakes via the c/i channel. the upstream unit issues a deactivation request and waits for a deactivation indication from all downstream units. once this is received, a deactivation confirmation is issued, followed by the stopping of dcl and fsc, and the placing of the output pin in a high impedance state. after the clocks are stopped, the input pin is monitored for the presence of a timing request from the downstream unit (the input pin being pulled low). the deactivation procedure is shown in figure 120 . after detecting the code diu (deactivate indication upstream) the layer 1 of the c165h responds by transmitting did (deactivate indication downstream) during subsequent frames and stops the timing signals synchronously with the end of the last c/i (c/i0) channel bit of the fourth frame. the detection of the dcl shut off is the same as in chapter 14.6.1. 14.6.3 activation request, downstream (c165h) to upstream the downstream unit can request that the clocks be restarted by pulling its data output line (du) low (this is called a timing request). in order to pull the output line to low, the bit iom_cr.spu must be set to ?1?. once the clocks are restarted, the downstream units requests activation by sending an activation request upstream over the c/i channel. after the clocks have been enabled, this may be indicated by the pu code in the c/i channel.the downstream unit may then insert a valid code in the c/i channel.the continuous supply of timing signals by the upstream unit is ensured as long as there is no di indication in the upstream c/i channel. if timing signals are no longer required and activation is not yet requested, the downstream unit may indicate this by sending di. 14.6.4 activation, upstream to downstream (c165h) the upstream unit activates the bus by starting the clocks and following the c/i channel- based activation handshake procedure (see figure 121 ). the dcl is directly connected to the fast interrupt which is held ?0? while the dcl clock is inactive. once the dcl is activated, the interrupt is triggered and the cpu can activate the iom-2 handler unit.
c165h iom-2 interface controller data sheet 332 2001-04-19 p r e l i m i n a r y - exc er p t - figure 121 activation of the iom-2 interface 14.7 hdlc controller the four hdlc controllers handle layer-2 functions of the d- channel protocol (lapd) or b-channel protocols. they can access each of the four iom-2 channels (b1, b2, d1, d2) at a time or any combination of them e.g. 18 bit idsl data (2b+d) by setting the enable hdlc channel bits (en_d1, en_b1h, en_b2h) in the iom_sel register. note: the tic bus d-channel access control feature is implemented for hdlc-2 controller only, please refer to chapter 14.4.4.1 , page 320. the hdlc controller perform the framing functions used in hdlc based communication: flag generation/recognition, bit stuffing, crc check and address recognition. itd09656 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ fsc du dd fsc du dd dcl spu = 1 spu = 0 cic : cixo = tim int. tim pu b1 b1 mx mr 0.2 to 4 ms 132 x dcl tim tim pu pu pu pu r iom -ch1 r iom -ch2 iom -ch2 r iom r -ch1
c165h iom-2 interface controller data sheet 333 2001-04-19 p r e l i m i n a r y - exc er pt - one 8 byte fifo for the receive and one for the transmit direction is available for each hdlc controller. note: in the following the description is focused on one hdlc controller only. the same information applies to all other hdlc controller as well, since they are identical with the exception of tic bus d-channel access control (as noted above). 14.7.1 message transfer modes a hdlc controller can be programmed to operate in various modes, which are different in the treatment of the hdlc frame in receive direction. thus the receive data flow and the address recognition features can be programmed in a flexible way to satisfy different system requirements. the structure of a lapd two-byte address is shown below. for the address recognition the hdlc controller contains four programmable registers for individual sapi and tei values (sap1, 2 and tei1, 2), plus two fixed values for the ?group? sapi (sapg = ?fe? or ?fc?) and tei (teig = ?ff?). the received c/r bit is excluded from the address comparison. ea is the address field extension bit which is set to ?1? for lapd protocol. there are 5 different operating modes which can be selected via the mode selection bits mds2-0 in the modeh register: 14.7.1.1 non-auto mode (mds2-0 = ?01x?) characteristics: full address recognition with one-byte (mds = ?010?) or two-byte (mds = ?011?) address comparison all frames with valid addresses are accepted and the bytes following the address are transferred to the p via rfifo. 14.7.1.2 transparent mode 0 (mds2-0 = ?110?). characteristics: no address recognition every received frame is stored in rfifo (first byte after opening flag to crc field). 14.7.1.3 transparent mode 1 (mds2-0 = ?111?). characteristics: sapi recognition a comparison is performed on the first byte after the opening flag with sap1, sap2 and ?group? sapi (fe h /fc h ). in the case of a match, all following bytes are stored in rfifo. high address byte low address byte sapi1, 2, sapg c/r 0 tei 1, 2, teig ea
c165h iom-2 interface controller data sheet 334 2001-04-19 p r e l i m i n a r y - exc er p t - 14.7.1.4 transparent mode 2 (mds2-0 = ?101?). characteristics: tei recognition a comparison is performed only on the second byte after the opening flag, with tei1, tei2 and group tei (ff h ). in case of a match the rest of the frame is stored in the rfifo. 14.7.1.5 extended transparent mode (mds2-0 = ?100?). characteristics: fully transparent in extended transparent mode fully transparent data transmission/reception without hdlc framing is performed i.e. without flag generation/recognition, crc generation/ check, bitstuffing mechanism. this allows user specific protocol variations. note: the extended transparent mode of the c165h is implemented according to the so called "lsb-first" methode. if the "msb-first" methode is needed, e.g. for voice traffic application, a look-up table using software could be applied. 14.7.2 data reception 14.7.2.1 general description the 8-byte rfifo is controlled by the cpu, which will act as master. the control of the data transfer between the cpu and the hdlc controller is handled via interrupts (hdlc controller cpu) and commands (cpu hdlc controller). there are four different interrupt indications in the istah register concerned with the reception of data: ? rpf ( r eceive p ool f ull) interrupt, indicating that a data word/byte can be read from rfifo. ? rme ( r eceive m essage e nd) interrupt, indicating that the reception of one message is completed. ? rfo ( r eceive f rame o verflow) interrupt, indicating that a complete frame could not be stored in rfifo and is therefore lost as the rfifo is occupied. this occurs if the cpu fails to respond quickly enough to rpf/rme interrupts since previous data was not read by the cpu. ? ffo ( f ollowing f rame o verflow) interrupt, indicating that a new frame could not be stored in the rfifo and therefore lost as the rfifo is occupied. this occurs if either there is still data in the rfifo of the previous frame or the cpu has not acknowledged the rme interrupt. acknowledgment is done by writing ?1? to the rme bit. there is one control command that is used with the reception of data: ? rres ( r eceiver r eset) command, resetting the hdlc receiver and clearing the receive fifo of any data (e.g. used before start of reception). it has to be used after having changed the mode.
c165h iom-2 interface controller data sheet 335 2001-04-19 p r e l i m i n a r y - exc er pt - 14.7.2.2 possible error conditions during reception of frames if parts of a frame get lost because the receive fifo is full, the receive data overflow (rdo) byte in the star register will be set. in addition, the rfo interrupt will be set. if a complete frame is lost the receiver will assert a receive frame overflow (rfo) interrupt or an following frame overflow (ffo) interrupt, depending on the situation. if the microcontroller reads data without a prior rme or rpf interrupt, the read data is undefined. 14.7.2.3 receive frame structure the management of the received hdlc frames as affected by the different operating modes is shown in figure 122 .
c165h iom-2 interface controller data sheet 336 2001-04-19 p r e l i m i n a r y - exc er p t - figure 122 receive data flow the hdlc controller indicates to the host that a new data block can be read from the rfifo by means of an rpf interrupt (see previous chapter). user data is stored in the rfifo and information about the received frame is available in the star and rbc registers which are listed in table 67 . flag fifoflow_rec.vsd mds0 mds2 mds1 mode ctrl crc flag i address control data status addr 0 01 non auto/8 tei1 tei2 rfifo star * 1) * 2) * 3) 0 11 transparent 0 rfifo star * 1) 1 01 non auto/16 sap1 sapg sap2 tei1 teig tei2 rfifo star * 1) * 2) * 2) 1 11 transparent 1 sap1 sapg sap2 rfifo star * 1) * 2) 1 10 transparent 2 rfifo star * 1) tei1 teig tei2 * 2) description of symbols: compared with registers stored in fifo/registers * 1) crc optionally stored in rfifo if modeh.rcrc = 1 * 2) address optionally stored in rfifo if modeh.sra = 1 * 3) start of the control field in case of a 8 bit address
c165h iom-2 interface controller data sheet 337 2001-04-19 p r e l i m i n a r y - exc er pt - 14.7.3 data transmission 14.7.3.1 general description the 8-byte register fifo buffer is controlled by the cpu for transmission. there are three different interrupt indications in the istah register concerned with the transmission of data: ? xpr ( t ransmit p ool r eady) interrupt, indicating that a data word/byte can be written to the tfifo. an xpr interrupt is generated either - after an xres (transmitter reset) command (which is issued for example for frame abort) or - when data from the tfifo is transmitted and the corresponding fifo can accept further data from the host. ? xdu ( t ransmit d ata u nderrun) interrupt, indicating that the transmission of the current frame has been aborted (seven consecutive ?1?s are transmitted) as the tfifo table 67 receive information at rme interrupt information location bit mode type of frame (command/ response) rfifo (last byte) c/r non-auto mode, 2-byte address field transparent mode 1 recognition of sapi rfifo (last byte) sa1, 0 non-auto mode, 2-byte address field transparent mode 1 recognition of tei rfifo (last byte) ta all except transparent mode 0 result of crc check (correct/incorrect) rfifo (last byte) crc all valid frame rfifo (last byte) vfr all abort condition detected (yes/no) rfifo (last byte) rab all data overflow during reception of a frame (yes/no) rfifo (last byte) rdo all message length rbc reg. rbc11-0 all rfifo overflow rbc reg. ov all
c165h iom-2 interface controller data sheet 338 2001-04-19 p r e l i m i n a r y - exc er p t - holds no further transmit data. this occurs if the host fails to respond to an xpr interrupt quickly enough. ? xmr ( t ransmit m essage r epeat) interrupt, indicating that the transmission of the complete last frame has to be repeated as, for example, a collision on the s bus has been detected. three different control commands are used for transmission of data: ? xtf ( t ransmit t ransparent f rame) command, telling the hdlc controller that a word/ byte has been written to the tfifo and should be transmitted. a start flag is generated automatically. ? xme ( t ransmit m essage e nd) command, telling the hdlc controller that the last data written to the tfifo completes the corresponding frame and should be transmitted. this implies that according to the selected mode a frame end (crc + closing flag) is generated and appended to the frame. ? xres ( t ransmitter r eset) command, resetting the hdlc transmitter and clearing the transmit fifo of any data. optionally one additional status conditions can be read by the host: ? xdov ( t ransmit d ata o verflow), indicating that the data block size has been exceeded, i.e. cpu writes to an occupied tfifo. the tfifo requests service from the microcontroller by setting a bit in the istah register, which causes an interrupt (xpr, xdu, xmr). the microcontroller can then read the status register star (xdov) and write data in the fifo. the instant of the initiation of a transmit pool ready (xpr) interrupt after different transmit control commands is listed in table 68 . when setting xme the transmitter appends the fcs and the endflag at the end of the frame. when xtf & xme has been set, the tfifo is locked until successful transmission of the current frame, so a consecutive xpr interrupt also indicates successful transmission of the frame whereas after xme or xtf the xpr interrupt is table 68 xpr interrupt (availability of the tfifo) after xtf, xme commands cmdr. transmit pool ready (xpr) interrupt initiated... xtf as soon as the selected buffer size in the fifo is available xtf & xme after the successful transmission of the closing flag. the transmitter sends always an abort sequence
c165h iom-2 interface controller data sheet 339 2001-04-19 p r e l i m i n a r y - exc er pt - asserted as soon as there is space for one data block in the tfifo. transmission in this conjunction means the hdlc controller has send all data to the iom-2 unit. the actual transmission of the bits on the iom-2 line can have some bcl cycles delay. 14.7.3.2 possible error conditions during transmission of frames if the transmitter sees an empty fifo, i.e. if the microcontroller does not react quickly enough to an xpr interrupt, an xdu (transmit data underrun) interrupt will be raised. if the hdlc channel becomes unavailable during transmission the transmitter tries to repeat the current frame as specified in the lapd protocol. this is impossible after the first data block has been sent (8 bytes), in this case an xmr transmit message repeat interrupt is set and the microcontroller has to send the whole frame again. both xmr and xdu interrupts cause a reset of the tfifo. the tfifo is locked while an xmr or xdu interrupt is pending, i.e. all write actions of the microcontroller will be ignored as long as the microcontroller has not read the istah register with the set xdu, xmr interrupts. if the microcontroller writes to a full fifo, the data in the tfifo will be corrupted and the star.xdov bit is set. if this happens, the microcontroller has to abort the transmission by cmdr.xres and to restart. 14.7.3.3 transmit frame structure the transmission of transparent frames (xtf command) is shown in figure 123 . for transparent frames, the whole frame including address and control field must be written to the tfifo. the host configures whether the crc is generated and appended to the frame (default) or not (selected in modeh.xcrc). furthermore, the host selects the interframe time fill signal which is transmitted between hdlc frames (modeh:itf). one option is to send continuous flags (?01111110?), however if d-channel access handling is required, the signal must be set to idle (continuous ?1?s are transmitted).
c165h iom-2 interface controller data sheet 340 2001-04-19 p r e l i m i n a r y - exc er p t - figure 123 transmit data flow 14.7.4 general access to iom-2 channels by setting the iomsel enable bits (en_d1, en_d2, en_b1, en_b2) in the iomsel register the hdlc controller can access each of the four iom-2 channels (b1, b2, d1, d2) or any combination of them (e.g. 18 bit idsl data (2b+d)) at a time). in all modes sending works always frame aligned, i.e. it starts with the first selected channel whereas reception looks for a flag anywhere in the serial data stream. the hardware is checking that no two hdlc controller have access to the same iom-2 channel. this is done according to following priority: ? channel 0 ... highest priority ? ..... ? channel 3 ... lowest priority. iom-2 channels (b1, b2, d1, d2), which are already allocated by higher prioritized hdlc controller can not be used by a hdlc channel with lower priority. if an iom-2 channel is enabled for lower prioritized hdlc channel and this iom-2 channel is also enabled for a higher prioritized hdlc channel than the enabling for the lower prioritized hdlc channel is reseted. 14.7.5 extended transparent mode this non-hdlc mode is selected by setting mode2...0 to ?100?. in extended transparent mode fully transparent data transmission/reception without hdlc framing is performed i.e. without flag generation/recognition, crc generation/check, bitstuffing mechanism. this allows user specific protocol variations. flag fifoflow_tran.vsd transmit transparent frame (xtf) ctrl crc flag i address control data checkram addr * 1) xfifo * 1) the crc is generated by default. if modeh.xcrc is set no crc is appended
c165h iom-2 interface controller data sheet 341 2001-04-19 p r e l i m i n a r y - exc er pt - 14.7.5.1 transmitter the transmitter sends the data out of the fifo without manipulation. transmission is always iom-frame aligned and byte aligned, i.e. transmission starts in the first selected channel (b1, b2, d1, d2, according to the setting of register iomsel in the iom handler) of the next iom frame. the fifo indications and commands are the same as in other modes. if the cpu sets xtf & xme the transmitter responds with an xpr interrupt after sending the last byte, then it returns to its idle state (sending continuous ?1?). if the collision detection is enabled (cic_cmd.dim = ?0x1?) the stop go bit (s/g) can be used as clear to send indication as in any other mode. if the s/g bit is set to ?1? (stop) during transmission the transmitter responds always with an xmr (transmit message repeat) interrupt. if the microcontroller fails to respond to a xpr interrupt in time and the transmitter runs out of data then it will assert an xdu (transmit data underrun) interrupt. 14.7.5.2 receiver the reception is iom-frame aligned and byte aligned, like transmission, i.e. reception starts in the first selected channel (b1, b2, d1, d2, according to the setting of register iomsel in the iom handler) of the next iom frame. the fifo indications and commands are the same as in others modes. all incoming data bytes are stored in the rfifo and additionally made available in star. if the fifo is full an rfo interrupt is asserted (modeh.sra = ?0?). note: in the extended transparent mode the modeh register bits has to be set to sra = ?0?, xcrc = ?0?, rcrc = ?0? and iff = ?0?. 14.7.6 hdlc controller interrupts 14.7.6.1 general hdlc interrupt the cause of an interrupt related to the hdlc controller (except fifo r/w) is indicated by the hdlc bit in the ista register. this bit points at the different interrupt sources of the hdlc controller part in the istah register. the individual interrupt sources of the hdlc controller during reception and transmission of data are explained the related chapters.
c165h iom-2 interface controller data sheet 342 2001-04-19 p r e l i m i n a r y - exc er p t - figure 124 interrupt status registers of the hdlc controller each interrupt source in istah register can be selectively masked by setting to ?1? the corresponding bit in maskh. all these interrupts (xdov, ffo, rme, rfo, xmr, xdu) are acknowledged by writing ?1? to the istah register. 14.7.6.2 hdlc transmit/receive fifo interrupt the rpf/xpr interrupt indicates that data can be read from rfifo written to the tfifo. to enable a fast action upon these interrupts there are two possibilities: 1. via the general interrupt line: the interrupt source (istah, xpr; istah, rpf) is (masked) mapped to the corresponding bit in the ista register 2. using a direct interrupt line: for hdlc controller 0 and 1 the xpr/rpf interrupts are mapped directly to individual interrupt lines. these lines are masked by the bits modeh.xpe and modeh.rpe. the direct interrupt lines can be used for pec handling of these interrupts. the xpr and rpf interrupts do not need to be acknowledged. the acknowledgment is done implicit in a read/write access to the specific fifo. rme rfo xmr xdu cic st mos rme rfo xmr xdu maskh istah 4x iomint ista mask cic st mos hdlc 4x hdlc 4x 4x 4x rpf rpf xpr xpr rpf rpf xpr 4x xpr 4x xdov ffo xdov ffo
c165h iom-2 interface controller data sheet 343 2001-04-19 p r e l i m i n a r y - exc er pt - 14.7.6.3 interrupt generation the source of each interrupt is, in general, a static signal. these signals are masked and propagated. a rising edge detection and pulse generation unit is placed at the output of each of the five iom-2 interrupts. this results in the generation of a new interrupt if the iomint line has been changed from ?0? to ?1?. this can occur:  if an interrupt occurs  by setting all mask bits and resetting them again 14.8 iom-2/hdlc controller register set this section summarizes all registers, which are implemented in the iom-2 module of the c165h and explains the description format. 14.8.1 register description format in the respective chapters the function and layout of the registers is described in a specific format which provides a number of deteils about the described register. the example below shows how to interpret these details. a register looks like this: reg_long_name elements:  reg_name: short name of the register  reg_name_long: long name of the register  address: 8 bit address given in hex format, relative to the base address of the iom-2 registers.  field: name of a bitfiled within the register. name: address: 00 h name: name: reg_name 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 field bits type value description bitfield_name 10:0 r/w 0 bitfield_long_name text++ text++ text reserved 15:11 these bits are reserved
c165h iom-2 interface controller data sheet 344 2001-04-19 p r e l i m i n a r y - exc er p t -  bits: the exact bits the bitfield occupies.  type: (r, w, r/w)= this bit is (only readable, only writable, read and writable) form the cpu.  description: contains the long name for the bitfield and further description.  value: the reset value of the bitfield. note: all reset values for bitfields of one bit length are given in binary form 0/1. for bitfields with more than one bit length they are given in decimal notation. for example, a four bit address name 3:0 with reset value ?12? must read ?1100? in binary notation. exceptions are marked with the subscript charackter ?h? for hex values. in this case, hex values reads always ?(bitfield length-1) downto 0?. note: bitfields marked as reserved may be used in further versions and their functionality is not guaranteed. they do not have any type or value specification. 14.8.2 register table ordered by address the following table lists all registers in the c165h iom-2 module ordered by their physical address. the address is an 8-bit address which is relative to the iom-2 base address. the base address for the iom-2 registers is 00ef00 h . table 69 iom-2 register set ordered by address 00ef00 h + ... register function 00 h iomclc iom-2 clock control register 02 h reserved 04 h reserved 06 h reserved 08 h iomid iom-2 identification register 0a h reserved 0c h reserved 0e h reserved 10 h cda_10 controller data access register 10 12 h cda_11 controller data access register 11 14 h cda_20 controller data access register 21 16 h cda_21 controller data access register 22 18 h cda_tsdp10 time slot and data port selection for cda 10 1a h cda_tsdp11 time slot and data port selection for cda 11 1c h cda_tsdp20 time slot and data port selection for cda 20
c165h iom-2 interface controller data sheet 345 2001-04-19 p r e l i m i n a r y - exc er pt - 1e h cda_tsdp21 time slot and data port selection for cda 21 20 h b1_tsdp time slot and data port selection for b1 22 h b2_tsdp time slot and data port selection for b2 24 h d1_tsdp time slot and data port selection for d1 26 h d2_tsdp time slot and data port selection for d2 28 h reserved 2a h reserved 2c h reserved 2e h reserved 30 h ista interrupt status register 32 h mask interrupt mask register 34 h cda1_cr control register for cda channel 1 36 h cda2_cr control register for cda channel 2 38 h cic_cr control register for control/indication channel 3a h mon_cr control register for monitor channel 3c h iom_cr control register for iom interface 3e h reserved 40 h sti synchronous transfer interrupt 42 h msti mask synchronous transfer interrupt 44 h asti acknowledge synchronous transfer interrupt 46 h reserved 48 h reserved 4a h reserved 4c h reserved 4e h reserved 50 h mor monitor receive channel 52 h mox monitor transmit channel 54 h mocr monitor control register 56 h msta monitor status register 58 h mosr monitor interrupt status register 5a h mcda mcda - monitoring cda bits 5c h reserved 5e h reserved table 69 iom-2 register set ordered by address (cont?d) 00ef00 h + ... register function
c165h iom-2 interface controller data sheet 346 2001-04-19 p r e l i m i n a r y - exc er p t - 60 h cic0_d command/indication channel 0 data 62 h cic1_d command/indication channel 1 data 64 h cic_cmd command/indication channel command register 66 h cic_st command/indication channel status register 68 h dcsi dcl clock supervision interval 6a h reserved 6c h reserved 6e h reserved 70 h reserved 72 h reserved 74 h reserved 76 h reserved 78 h reserved 7a h reserved 7c h reserved 7e h reserved 80 h rfifo_0 receive fifo (hdlc-channel 0) 82 h tfifo_0 transmit fifo (hdlc-channel 0) 84 h istah_0 interrupt status register (hdlc-channel 0) 86 h maskh_0 interrupt mask register (hdlc-channel 0) 88 h star_0 status register (hdlc-channel 0) 8a h cmdr_0 command register (hdlc-channel 0) 8c h iomsel_0 iom-2 channel selection (hdlc-channel 0) 8e h modeh_0 mode register (hdlc-channel 0) 90 h sap1_0 sapi1 register (hdlc-channel 0) 92 h sap2_0 sapi2 register (hdlc-channel 0) 94 h rbc_0 receive frame byte count (hdlc-channel 0) 96 h tei1_0 tei1 register (hdlc-channel 0) 98 h tei2_0 tei2 register (hdlc-channel 0) 9a h looph_0 looping register (hdlc-channel 0) 9c h reserved 9e h reserved a0 h rfifo_1 receive fifo (hdlc-channel 1) table 69 iom-2 register set ordered by address (cont?d) 00ef00 h + ... register function
c165h iom-2 interface controller data sheet 347 2001-04-19 p r e l i m i n a r y - exc er pt - a2 h tfifo_1 transmit fifo (hdlc-channel 1) a4 h istah_1 interrupt status register (hdlc-channel 1) a6 h maskh_1 interrupt mask register (hdlc-channel 1) a8 h star_1 status register (hdlc-channel 1) aa h cmdr_1 command register (hdlc-channel 1) ac h iomsel_1 iom-2 channel selection (hdlc-channel 1) ae h modeh_1 mode register (hdlc-channel 1) b0 h sap1_1 sapi1 register (hdlc-channel 1) b2 h sap2_1 sapi2 register (hdlc-channel 1) b4 h rbc_1 receive frame byte count (hdlc-channel 1) b6 h tei1_1 tei1 register (hdlc-channel 1) b8 h tei2_1 tei2 register (hdlc-channel 1) ba h loop_1 looping register (hdlc-channel 1) bc h reserved be h reserved c0 h rfifo_2 receive fifo (hdlc-channel 2) c2 h tfifo_2 transmit fifo (hdlc-channel 2) c4 h istah_2 interrupt status register (hdlc-channel 2) c6 h maskh_2 interrupt mask register (hdlc-channel 2) c8 h star_2 status register (hdlc-channel 2) ca h cmdr_2 command register (hdlc-channel 2) cc h iomsel_2 iom-2 channel selection (hdlc-channel 2) ce h modeh_2 mode register (hdlc-channel 2) d0 h sap1_2 sapi1 register (hdlc-channel 2) d2 h sap2_2 sapi2 register (hdlc-channel 2) d4 h rbc_2 receive frame byte count (hdlc-channel 2) d6 h tei1_2 tei1 register (hdlc-channel 2) d8 h tei2_2 tei2 register (hdlc-channel 2) da h loop_2 looping register (hdlc-channel 2) dc h reserved de h reserved e0 h rfifo_3 receive fifo (hdlc-channel 3) e2 h tfifo_3 transmit fifo (hdlc-channel 3) table 69 iom-2 register set ordered by address (cont?d) 00ef00 h + ... register function
c165h iom-2 interface controller data sheet 348 2001-04-19 p r e l i m i n a r y - exc er p t - e4 h istah_3 interrupt status register (hdlc-channel 3) e6 h mask_3 interrupt mask register (hdlc-channel 3) e8 h star_3 status register (hdlc-channel 3) ea h cmdr_3 command register (hdlc-channel 3) ec h iomsel_3 iom-2 channel selection (hdlc-channel 3) ee h modeh_3 mode register (hdlc-channel 3) f0 h sap1_3 sapi1 register (hdlc-channel 3) f2 h sap2_3 sapi2 register (hdlc-channel 3) f4 h rbc_3 receive frame byte count (hdlc-channel 3) f6 h tei1_3 tei1 register (hdlc-channel 3) f8 h tei2_3 tei2 register (hdlc-channel 3) fa h loop_3 looping register (hdlc-channel 3) fc h reserved fe h reserved table 69 iom-2 register set ordered by address (cont?d) 00ef00 h + ... register function
c165h iom-2 interface controller data sheet 349 2001-04-19 p r e l i m i n a r y - exc er pt - 14.8.3 detailed register description ordered by address iom-2 clock control register the register iomclc is clocked with the bus clock to be able to switch the iom-2 interface controller clock on again, if it was off. if required, switching off the clock can be prevented by the iom-2 controller. address: 00 h name: iomclc 151413121110987654 3210 reserved iom ex_dis iom gpsen iom dis iom disr field bits type value description iomex_dis 3 r/w 0 iom-2 controller clock disable 0: the clock of the iom-2 interface controller is enabled, normal operation. 1: the clock of the iom-2 interface controller is disabled. iomgpsen 2 r/w 0 iom-2 controller clock ocds disable 0: the clock of the iom-2 interface controller is enabled, normal operation. 1: the clock of the iom-2 interface controller is disabled during debugging mode (ocds) iomdis 1 r 0 iom-2 controller clock status 0: the status of the iom-2 interface controller clock is ? enabled ? . 1: the status of the iom-2 interface controller clock is ? disabled ? . iomdisr 0 r/w 0 iom-2 controller clock disable 0: the clock of the iom-2 interface controller is enabled, normal operation. 1: the clock of the iom-2 interface controller is disabled. reserved 15:4 - 0 these bits are reserved
c165h iom-2 interface controller data sheet 350 2001-04-19 p r e l i m i n a r y - exc er p t - the state of the iom-2 interface controller clock is controlled by the register bit iomdisr. the actual clock state will be shown by the state bit iomdis. for on chip debugging support (ocds) an additional bit iomgpsen is introduced to stop the peripheral clock for arbitrary lengths of time during debugging if this function is enabled. if debugging mode is active, the peripheral core rejects write access to registers connected to the peripheral clock. to be compatible with previous c16x products an iomex_disr signal is provided to disable the peripheral clock. iom-2 identification register controller data access register xy (x=1,2; y =0,1) name: 08 h name: iomid 1514131211109876543210 id field bits type value description id 15:0 r 0 iom-2 identification register address: 10 h 12 h 14 h 16 h name: cda_10 cda_11 cda_20 cda_21 1514131211109876543210 reserved cda_xy field bits type value description cda_xy 7:0 r/w ff h data register which can be accessed from the cpu. reserved 15:8 r these bits are reserved.
c165h iom-2 interface controller data sheet 351 2001-04-19 p r e l i m i n a r y - exc er pt - time slot and data port selection for cda_xy (x=1,2; y =0,1) this register determines the time slots and the data ports on the iom-2 interface for the data channels xy of the functional unit cda (controller data access). note: for the cda (controller data access) data the input is determined by the cda_crx.swap bit. if swap = ?0? the input for the cdaxy data is vice versa to the output setting for cdaxy. if the swap = ?1? the input from cdax0 is vice versa to the output setting of cdax1 and the input from cdax1 is vice versa to the output setting of cdax0. see controller data access description in chapter 14.5. address: 18 h 1a h 1c h 1e h address: cda_tsdp10 cda_tsdp11 cda_tsdp20 cda_tsdp21 1514131211109876543210 dps reserved tss field bits type value description dps(10) (11) (20) (21) 15 r/w 0 0 1 1 data port selection 0: the data channel xy of the functional unit cda is output on dd and input from du. 1: the data channel xy of the functional unit cda is output on du and input from dd. tss(10) (11) (20) (21) 4:0 r/w 0 1 0 1 time slot selection selects one of 32 timeslots (0..31) of the iom-interface for the data channels. reserved 14:5 r these bits are reserved.
c165h iom-2 interface controller data sheet 352 2001-04-19 p r e l i m i n a r y - exc er p t - time slot and data port selection for the 8-bit hdlc channel b1 time slot and data port selection for the 8-bit hdlc channel b2 address: 20 h name: b1_tsdp 1514131211109876543210 dps reserved tss field bits type value description dps 15 w 0 data port selection 0: the data of the 8-bit hdlc channel b1 is output on dd and input from du. 1: the data of the first 8-bit hdlc channel b1 is input from dd and output on du. tss 4:0 w 0 time slot selection selects one of 32 timeslots (0..31) of the iom-interface for the 8-bit hdlc channel b1. reserved 14:5 r these bits are reserved. address: 22 h name: b2_tsdp 1514131211109876543210 dps reserved tss field bits type value description dps 15 w 0 data port selection 0: the data of the 8-bit hdlc channel b2 is output on dd and input from du. 1: the data of the 8-bit hdlc channel b2 is input from dd and output on du. tss 4:0 w 0 time slot selection selects one of 32 timeslots (0..31) of the iom-interface for the 8-bit hdlc channel b2.
c165h iom-2 interface controller data sheet 353 2001-04-19 p r e l i m i n a r y - exc er pt - time slot and data port selection for the 2-bit hdlc channel d1 note: d1 channel access always starts with bit 7 (msb) on the iom/pcm timeslot. reserved 14:5 r 0 these bits are reserved. address: 24 h name: d1_tsdp 1514131211109876543210 dps reserved tss field bits type value description dps 15 w 0 data port selection 0: the data of the 2-bit hdlc channel d1 is output on dd and input from du. 1: the data of the 2-bit hdlc channel d1 is input from dd and output on du. tss 4:0 w 0 time slot selection selects one of 32 timeslots (0..31) of the iom-interface for the 2-bit hdlc channel d1. reserved 14:5 r 0 these bits are reserved. field bits type value description
c165h iom-2 interface controller data sheet 354 2001-04-19 p r e l i m i n a r y - exc er p t - time slot and data port selection for the 2-bit hdlc channel d2 note: d2 channel access always starts with bit 7 (msb) on the iom/pcm timeslot. interrupt status register address: 26 h name: d2 _tsdp 1514131211109876543210 dps reserved tss field bits type value description dps 15 w 0 data port selection 0: the data of the 2-bit hdlc channel d2 is output on dd and input from du. 1: the data of the 2-bit hdlc channel d2 is input from dd and output on du. tss 4:0 w 0 time slot selection selects one of 32 timeslots (0..31) of the iom-interface for the 2-bit hdlc channel d2. reserved 14:5 r 0 these bits are reserved. address: 30 h name: ista 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 rpf 3 rpf 2 rpf 1 rpf 0 xpr 3 xpr 2 xpr 1 xpr 0 dcsi st cic mos hdlc 3 hdlc 2 hdlc 1 hdlc 0 field bits type value description hdlc3..0 3:0 r 0 hdlc channel interrupts the hdlc controller (0..3) has one of the following interrupt sources: rme, rfo, ffo, xmr, xdu, or xdov. mos 4 r 0 monitor status a change in the monitor status register (mosr) has occured.
c165h iom-2 interface controller data sheet 355 2001-04-19 p r e l i m i n a r y - exc er pt - note: dcsi is the only physical flip flop in the ista register. all other bits are multiplexed from different sources in the iom-2 unit. for all interrupts in the ista register the following states are applied: 0: interrupt is not activated 1: interrupt is activated cic 5 r 0 c/i channel change a change in c/i channel 0 or c/i channel 1 has been recognized. the actual value can be read from cic_st. st 6 r 0 synchronous transfer when programmed (sti register), this interrupt is generated to enable the microcontroller to lock on to the iom timing, for synchronous transfers. dcsi 7 r 0 dcl clock status interrupt a change in the cic_st.dcod (dcl clock off detection) status flag has occured. xpr3..0 11:8 r 0 transmit pool ready for hdlc channel x (x = 0..3) this is the masked / unmasked xpr interrupt from istah_x.xpr. xpr is used for faster reaction of the sw to the transmit fifo interrupts. rpf3..0 15:12 r 0 receive pool full for hdlc channel x (x = 0..3) this is the masked/unmasked rpf interrupt from istah_x.rpf. rpf is used for faster reaction of th sw to the receive fifo interrupts. field bits type value description
c165h iom-2 interface controller data sheet 356 2001-04-19 p r e l i m i n a r y - exc er p t - interrupt mask register the mask register is related to the ista register, page 354. using the mask register, all interrupts of the ista register can be masked. for all mask interrupts in the mask register the following states are applied: 0: interrupt is not masked 1: interrupt is masked address: 32 h name: mask 1514131211109876543210 rpf 3 rpf 2 rpf 1 rpf 0 xpr 3 xpr 2 xpr 1 xpr 0 dcsi st cic mos hdlc 3 hdlc 2 hdlc 1 hdlc 0 field bits type value description hdlc3..0 3:0 r/w f h hdlc channel x interrupts mask mos 4 r/w 1 monitor status mask cic 5 r/w 1 c/i channel change mask st 6 r/w 1 synchronous transfer mask dcsi 7 r/w 1 dcl clock status interrupt mask xpr3..0 11:8 r/w f h transmit pool ready for hdlc channel x mask rpf3..0 15:12 r/w f h receive pool full for hdlc channel x mask
c165h iom-2 interface controller data sheet 357 2001-04-19 p r e l i m i n a r y - exc er pt - control register for controller data access chx (x = 1,2) address: 34 h 36 h name: cda1_cr cda2_cr 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 reserved en_i1 en_i0 en_o1 en_o0 swap field bits type value description en_i1 en_i0 4 3 r/w r/w 0 0 enable input cdax0, cdax1 0: the input of the cdax0, cdax1 register is disabled 1: the input of the cdax0, cdax1 register is enabled en_o1 en_o0 2 1 r/w r/w 0 0 enable output cdax0, cdax1 0:the output of the cdax0, cdax1 register is disabled 1: the output of the cdax0, cdax1 register is enabled swap 0 r/w 0 swap inputs 0: the time slot and data port for the input of the cdaxy register is defined by its own cda_tsdpxy register. the data port for the cdaxy input is vice versa to the output setting for cdaxy. 1: the input (time slot and data port) of the cdax0 is defined by the tsdp register of cdax1 and the input of cdax1 is defined by the tsdp register of cdax0. the data port for the cdax0 input is vice versa to the output setting for cdax1. the data port for the cdax1 input is vice versa to the output setting for cdax0. the input definition for time slot and data port cdax0 are thus swapped to cdax1 and for cdax1 to cdax0. the outputs are not affected by the swap bit.
c165h iom-2 interface controller data sheet 358 2001-04-19 p r e l i m i n a r y - exc er p t - control register for control/indication channel address: 38 h name: cic_cr 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 dps_c i1 en_ci 1 reserved dps_ ci0 en_ci 0 reserved field bits type value description en_ci0 6 r/w 0 enable ci0 data 0: ci0 data is disabled 1: ci0 data is enabled dps_ci0 7 r/w 1 data port selection ci0 data 0: the ci0 data is output on dd and input from du 1: the ci0 data is output on du and input from dd en_ci1 14 r/w 0 enable ci1 data 0: ci1 data is disabled 1: ci1 data is enabled dps_ci1 15 r/w 1 data port selection ci1 data 0: the ci1 data is output on dd and input from du 1: the ci1 data is output on du and input from dd reserved 13:8, 5:0 r these bits are reserved
c165h iom-2 interface controller data sheet 359 2001-04-19 p r e l i m i n a r y - exc er pt - control register for monitor channel address: 3a h name: mon_cr 1514131211109876543210 en_m on reserved dps reserved mcs field bits type value description en_mon 15 r/w 1 enable output 0: the monitor data input and output is disabled 1: the monitor data input and output is enabled dps 7 r/w 0 data port selection 0: the monitor data is output on dd and input from du 1: the monitor data is output on du and input from dd mcs 2:0 r/w 0 monitor channel selection 000: the monitor data is input/output on mon0 (3rd timeslot on iom-2) 001: the monitor data is input/output on mon1 (7th timeslot on iom-2) 010: the monitor data is input/output on mon2 (11th timeslot on iom-2) ... 111: the monitor data is input/output on mon7 (31st timeslot on iom-2) reserved 14:8, 6:3 r these bits are reserved
c165h iom-2 interface controller data sheet 360 2001-04-19 p r e l i m i n a r y - exc er p t - control register for the iom-2 interface address: 3c h name: iom_cr 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 reserved spu dis_od clkm dis_iom field bits type value description dis_iom 0 r/w 0 disable iom dis_iom should b set to ? 1 ? if external devices connected to the iom interface should be ? disconnected ? , e.g. for power savings purposes. 0: the iom interface is enabled 1: the iom interface is disabled (high impendance) clkm 1 r/w 0 clock mode 0: a double bit clock is connected to dcl 1: a single bit clock is connected to dcl dis_od 2 w/r 0 open_drain 0: iom outputs are open drain driver 1: iom outputs are push pull driver spu 3 r/w 0 software power up 0: the du line is normally used for trans mitting data. 1: setting this bit to ? 1 ? will pull the du line to low. this will enforce con- nected layer 1 devices to deliver iom- clocking. after a subsequent ista:cic-interrupt (c/ i-code change) and reception of the c/i- code ? pu ? (power up indication in te- mode) the user has to write an ar or tim command as c/i-code in the cix0- register, resets the spu bit and waits for the following cic-interrupt. reserved 15:4 r these bits are reserved
c165h iom-2 interface controller data sheet 361 2001-04-19 p r e l i m i n a r y - exc er pt - synchronous transfer interrupt for all interrupts in the sti register following logical states are applied: 0:interrupt is not acitvated 1:interrupt is acitvated note: st0vxy and ackxy are useful for synchronizing microcontroller accesses and receive/transmit operations. one bcl clock is equivalent to two dcl clocks. address: 40 h name: sti 151413121110987 6543210 reserved stov 21 stov 20 stov 11 stov 10 sti 21 sti 20 sti 11 sti 10 field bits type value description stov21 stov20 stov11 stov10 7 6 5 4 r r r r 0 0 0 0 synchronous transfer overflow interrupt enabled stov interrupts for a certain stixy interrupt are generated when the stixy has not been acknowledged in time via the ackxy bit in the asti register. this must be one (for dps= ? 0 ? ) or zero (for dps= ? 1 ? ) bcl clocks before the time slot which is selected for the stov. sti21 sti20 sti11 sti10 3 2 1 0 r r r r 0 0 0 0 synchronous transfer interrupt depending on the dps bit in the corresponding tsdpxy register the synchronous transfer interrupt stixy is generated two (for dps= ? 0 ? ) or one (for dps= ? 1 ? ) bcl clock after the selected time slot (tsdpxy.tss). reserved 15:8 r 0 these bits are reserved
c165h iom-2 interface controller data sheet 362 2001-04-19 p r e l i m i n a r y - exc er p t - mask synchronous transfer interrupt for the msti register following logical states are applied: 0:interrupt is not masked 1:interrupt is masked address: 42 h name: msti 151413121110987 6543210 reserved stov 21 stov 20 stov 11 stov 10 sti 21 sti 20 sti 11 sti 10 field bits type value description stov21 stov20 stov11 stov10 7 6 5 4 r/w r/w r/w r/w 1 1 1 1 synchronous transfer overflow for stixy by masking the stov bits the number and time of the stov interrupts for a certain enabled stixy interrupt can be controlled. for an enabled stixy the own stovxy is generated when the stovxy is enabled (msti.stixy and msti.stovxy = ? 0 ? ). additionally all other stov interrupts of which the corresponding sti is disabled (msti.sti = ? 1 ? and msti.stov = ? 0 ? ) are generated. sti21 sti20 sti11 sti10 3 2 1 0 r/w r/w r/w r/w 1 1 1 1 synchronous transfer interrupt xy the stixy interrupts can be masked by setting the corresponding mask bit to ? 1 ? . for a masked stixy no stov interrupt is generated. reserved 15:8 r 0 these bits are reserved
c165h iom-2 interface controller data sheet 363 2001-04-19 p r e l i m i n a r y - exc er pt - acknowledge synchronous transfer interrupt monitor receive channel address: 44 h name: asti 151413121110987 6543210 reserved ack 21 ack 20 ack 11 ack 10 field bits type value description ack21 ack20 ack11 ack10 3 2 1 0 w w w w 0 0 0 0 acknowledge synchronous transfer interrupt after a stixy interrupt the microcontroller has to acknowledge the interrupt by setting the corresponding ackxy bit. 0: no activity is initiated 1: sets the acknowledge bit ackxy for a stixy interrupt reserved 15:4 r 0 these bits are reserved address: 50 h name: mor 151413121110987 6543210 reserved mor field bits type value description mor 7:0 r ff monitor data received contains the monitor data received in the iom-2 monitor channel according to the monitor channel protocol. the monitor channel (0 ... 7) can be selected by setting the monitor channel select bits mon_cr.mcs.
c165h iom-2 interface controller data sheet 364 2001-04-19 p r e l i m i n a r y - exc er p t - monitor transmit channel monitor control register reserved 15:8 r 0 these bits are reserved address: 52 h name: mox 151413121110987 6543210 reserved mox field bits type value description mox 7:0 w ff monitor data transmitted contains the monitor data to be transmitted in iom-2 monitor channel according to the monitor channel protocol.the monitor channel (0 ... 7) can be selected by setting the monitor channel select bits mon_cr.mcs reserved 15:8 r 0 these bits are reserved address: 54 h name: mocr 151413121110987 6543210 reserved mre mrc mie mxc field bits type value description mre 3 r/w 0 monitor receive interrupt enable 0: monitor interrupt status mdr generation is masked 1: monitor interrupt status mdr generation is enabled field bits type value description
c165h iom-2 interface controller data sheet 365 2001-04-19 p r e l i m i n a r y - exc er pt - monitor status register mrc 2 r/w 0 mr bit control determines the value of the mr bit: 0: mr is always ? 1 ? . in addition, the mdr interrupt is blocked, except for the first byte of a packet (if mre = 1). 1: mr is internally controlled according to the monitor channel protocol. in addition, the mdr interrupt is enabled for all received bytes according to the monitor channel protocol (if mre = ? 1 ? ). mie 1 r/w 0 monitor interrupt enable monitor interrupt status mer, mda, mab generation is enabled (1) or masked (0). mxc 0 r/w 0 mx bit control determines the value of the mx bit: 0: the mx bit is always ? 1 ? . 1: the mx bit is internally controlled according to the monitor channel protocol. reserved 15:4 r 0 these bits are reserved address: 56 h name: msta 151413121110987 6543210 mac reserved field bits type value description mac 15 r 0 monitor transmit channel active the data transmisson in the monitor channel is in progress reserved 14:0 r 0 these bits are reserved field bits type value description
c165h iom-2 interface controller data sheet 366 2001-04-19 p r e l i m i n a r y - exc er p t - monitor interrupt status register note: these interrupt status bits can be polled, i.e. a ?read? does not reset these interrupts. to reset a specific interrupt a ?1? must be written to the specific interrupt bit. monitoring cda bits address: 58 h name: mosr 151413121110987 6543210 reserved mdr mer mda mab field bits type value description mdr 3 r/w 0 monitor channel data received mer 2 r/w 0 monitor channel end of reception mda 1 r/w 0 monitor channel data acknowledge the remote end has acknowledged the monitor byte being transmitted. mab 0 r/w 0 monitor channel data abort reserved 15:4 r 0 these bits are reserved address: 5a h name: mcda 151413121110987 6543210 reserved mcda21 mcda20 mcda11 mcda10 field bits type value description mcda21 mcda20 mcda11 mcda10 7:6 5:4 3:2 1:0 r r r r 03 03 03 03 monitoring cdaxy bits bit 7 and bit 6 of the cdaxy registers are mapped into the mcda register. this can be used for monitoring the d-channel bits on du and dd and the ? echo bits ? on the tic bus with the same register.
c165h iom-2 interface controller data sheet 367 2001-04-19 p r e l i m i n a r y - exc er pt - command/indication channel 0 data note: the codr0 bits are updated every time a new c/i-code is detected in two consecutive iom-frames. if several consecutive valid new codes are detected and cir0 is not read, only the first and the last c/i code is made available in codr0 at the first and second read of that register, respectively. reserved 15:4 r 00 these bits are reserved address: 60 h name: cic0_d 151413121110987 6543210 reserved codr0 reserved codx0 field bits type value description codx0 3:0 w f h c/i-code 0 transmit code to be transmitted in the c/i-channel 0. codr0 11:8 r f h c/i code 0 receive value of the received command/ indication code. a c/i-code is loaded in codr0 only after being the same in two consecutive iom-frames and the previous code has been read from cir0. reserved 15:12, 7:4 r0 h these bits are reserved field bits type value description
c165h iom-2 interface controller data sheet 368 2001-04-19 p r e l i m i n a r y - exc er p t - cic1_d - command/indication channel 1 data command/indication channel command register address: 62 h name: cic1_d 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 reserved codr1 reserved codx1 field bits type value description codx1 5:0 w 3f h c/i-code 1 transmit bits 7-2 of c/i-channel 1 codr1 13:8 r 3f h c/i-code 1 receive value of the received command/ indication code. reserved 15,14 7,6 r ? 00 ? these bits are reserved address: 64 h name: cic_cmd 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 reserved dim res erv ed tic_ dis ci1e cicw bac tba field bits type value description tba 2:0 w 7 tic bus address defines the individual address for the c165h on the iom-2 bus. this address is used to access the c/i- and d-channel on the iom interface. note: if only one device is liable to transmit in the c/i- and d-channels of the iom it should always be given the address value "111".
c165h iom-2 interface controller data sheet 369 2001-04-19 p r e l i m i n a r y - exc er pt - bac 3 w 0 bus access control only valid if the tic-bus feature is enabled (mode:dim2-0). if this bit is set, the c165h will try to access the tic-bus to occupy the c/i- channel even if no d-channel frame has to be transmitted. it should be reset when the access has been completed to grant a similar access to other devices transmitting in that iom-channel. note: if the tic-bus address (tba2-0) is programmed to ?7? and is not blocked by another device the c165h writes its c/i0 code to iom continuously. cicw 4 w 1 c/i-channel width cicw selects between a 4 bit ( ? 0 ? ) and 6 bit ( ? 1 ? ) c/i1 channel width ci1e 5 w 0 c/i-channel 1 interrupt enable interrupt generation ista.cic of cir0.cic1 is enabled (1) or masked (0). disabling the interrupt disables the cic1 status indication. tic_dis 6 r/w 0 tic bus disable 0: the last octet of iom channel 2 (11 th time slot) is used as tic bus (te mode only). 1: the tic bus is disabled. the last octet of the last iom time slot (11 th time slot) can be used as every time slot. dim 10:8 r/w 4 digital interface modes these bits define the characteristics of the iom data ports (du, dd). the dim0 bit enables/disables the collission detection. the dim1 bit enables/disables the tic bus access. the effect of the individual dim bits is summarized in table 70 . reserved 15:7 r these bits are reserved field bits type value description
c165h iom-2 interface controller data sheet 370 2001-04-19 p r e l i m i n a r y - exc er p t - command/indication channel status register table 70 dim bit setting dim2 dim1 dim0 characteristics 0x0 transparent d-channel, the collission detection is disabled 0x1 stop/go bit evaluated for d-channel access handling 00x last octet of iom channel 2 used for tic bus access 01x tic bus access is disabled 1xx reserved address: 66 h name: cic_st 151413121110 9 8 7 65432 1 0 cic0 cic1 s/g bas reserved dcod reserved field bits type value description dcod 7 r 0 dcl clock off detection indicates the value of the dcl clock detection counter: 0: value of the dcl clock detection counter is greater than zero 1: value of the dcl clock detection counter is zero bas 12 r 1 bus access status indicates the state of the tic-bus: 0: the c165h itself occupies the d- channel 1: another device or no device occupies the d-channel s/g 13 r 1 stop/go bit monitoring indicates the availability of the d-channel on the line interface. 0: go 1: stop
c165h iom-2 interface controller data sheet 371 2001-04-19 p r e l i m i n a r y - exc er pt - dcl clock supervision interval cic1 14 r 0 c/i code 1 change a change in the received command/ indication code in iom-channel 1 has been recognized. this bit is set when a new code is detected in one iom-frame. it is reset by a read of cir0. cic0 15 r 0 c/i code 0 change a change in the received command/ indication code has been recognized. this bit is set only when a new code is detected in two consecutive iom-frames. it is reset by a read of cir0. reserved 11:8, 6:0 r these bits are reserved address: 68 h name: dcsi 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 reserved dcsi_val field bits type value description dcsi_val 10:0 r/w 00 dcl clock supervision interval value contains the initial value for the dcl clock supervision 11-bit counter (see chapter supervision). reserved 15:11 r 00 these bits are reserved field bits type value description
c165h iom-2 interface controller data sheet 372 2001-04-19 p r e l i m i n a r y - exc er p t - 14.8.4 hdlc-channel registers the register set for the hdlc-channels is identical for each of the 4 channels. therefore, the hdlc-channel registers are described only once. the start address for each hdlc-channel is given below: the detailed hdlc-channel register description, given in this chapter, contains the relative address only. receive fifo hdlc-channel start address (s_adr_x) hd0 80 hd1 a0 hd2 c0 hd3 e0 address: s_adr_x + 00 h name: rfifo_x 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 data field bits type value description data 15:0 r 0000 h provides word read access to the next valid data. after an istah.rpf interrupt, a complete data word is available. after an istah.rme interrupt, the number of received bytes can be obtained by reading the rbcl register.
c165h iom-2 interface controller data sheet 373 2001-04-19 p r e l i m i n a r y - exc er pt - transmit fifo interrupt status register address: s_adr_x + 02 h name: tfifo_x 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 data field bits type value description data 15:0 w 0000 h a write access provides data to the tfifo. up to ten bytes of transmit data can be written to the tfifo following an istah.xpr interrupt. data can be written either word wide or byte wide (with the valid byte at low position) address: s_adr_x + 04 h name: istah_x 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 rme rpf rfo ffo reserved xpr xmr xdu xdov reserved field bits type value description rme 15 r 0 receive message end the end of a frame has been received. the message length and additional information may be obtained from rbch, rbcl and the star register. rpf 14 r 0 receive pool full a data word/byte has been received and is available in the rfifo.
c165h iom-2 interface controller data sheet 374 2001-04-19 p r e l i m i n a r y - exc er p t - rfo 13 r 0 receive frame overflow the received data of a frame could not be stored, because the rfifo is occupied. the whole message is lost and the fifo is flushed. this interrupt can be used for statistical purposes and indicates that the microcontroller does not respond quickly enough to an rpf or rme interrupt (istah). ffo 12 r 0 following frame overflow this interrupt occurs if a new frame is received while the previous frame still occupies the fifo. the new frame will be rejected. xpr 7 r 0 transmit pool ready a data word/byte can be written to the tfifo. an xpr interrupt will be generated if the transmit fifo can accept data and if the xme flag is not set. xmr 6 r 0 transmit message repeat the transmission of the last frame has to be repeated because a collision has been detected. xdu 5 r 0 transmit data underrun the current transmission of a frame is aborted by transmitting seven ? 1 ? s because the tfifo holds no further data. this interrupt occurs whenever the cpu has failed to respond to an xpr interrupt (istah register) quickly enough, after having initiated a transmission and the message to be transmitted is not yet complete. xdov 4 r 0 transmit data overflow data has been written to the fifo although the fifo is full, e.g. data has been lost. field bits type value description
c165h iom-2 interface controller data sheet 375 2001-04-19 p r e l i m i n a r y - exc er pt - interrupt mask register each interrupt source in the istah register can be selectively masked by setting to ? 1 ? the corresponding bit in maskh. masked interrupt status are still indicated when istah is read. all mask bits are set after reset (reset value ffff h ). status register reserved 11:8, 3:0 r these bits are reserved address: s_adr_x + 06 h name: maskh_x 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 rme rpf rfo ffo reserved xpr xmr xdu xdov reserved address: s_adr_x + 08 h name: star_x 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 vfr rdo crc rab sa1 sa0 c/r ta raci reserved xaci field bits type value description raci 7 r 0 receiver active indication the hdlc receiver is active when raci = ? 1 ? . this bit may be polled. the raci bit is set active after a begin flag has been received and is reset after receiving an abort sequence. field bits type value description
c165h iom-2 interface controller data sheet 376 2001-04-19 p r e l i m i n a r y - exc er p t - vfr 15 r 0 valid frame determines whether a valid frame has been received. the frame is valid (1) or invalid (0). a frame is invalid when there is not a multiple of 8 bits between flag and frame end (flag, abort). rdo 14 r 0 receive data overflow if rdo=1, at least one byte of the frame has been lost, because it could not be stored in rfifo. xaci 0 r 0 transmitter active indication the hdlc-transmitter is active when xaci = ? 1 ? . this bit may be polled. the xaci-bit is active when an xtf-command is issued and the frame has not been completely transmitted. crc 13 r 0 crc check the crc is correct (1) or incorrect (0). rab 12 r 0 receive message aborted the receive message was aborted by the remote station (1), i.e. a sequence of seven 1 ? s was detected before a closing flag. sa1 sa0 ta 11 10 8 r r r 1 1 0 sapi address identification tei address identification sa1-0 are significant in non-auto-mode with a two-byte address field, as well as in transparent mode 3. ta is significant in all modes except in transparent modes 0 and 1. two programmable sapi values (sap1, sap2) plus a fixed group sapi (sapg of value fc/fe h ), and two programmable tei values (tei1, tei2) plus a fixed group tei (teig of value ff h ), are available for address comparison. the result of the address comparison is given by sa1-0 and ta, shown in table 71. field bits type value description
c165h iom-2 interface controller data sheet 377 2001-04-19 p r e l i m i n a r y - exc er pt - c/r 9 r 0 command/response the c/r bit contains the c/r bit of the received frame (bit1 in the sapi address) note: the contents of star corresponds to the last received hdlc frame; it is duplicated into rfifo for every frame (last byte of frame) note: if sap1 and sap2 contains identical values, the combination 001 will be omitted. reserved 6:1 r these bits are reserved table 71 the result of the address comparison, given by sa1-0 and ta address match with sa1 sa0 ta 1 st byte 2 nd byte number of address bytes = 1 x x x x 0 1 tei2 tei1 - - number of address bytes = 2 0 0 0 0 1 1 1 0 0 1 1 0 0 1 0 1 0 1 0 1 x sap2 sap2 sapg sapg sap1 sap1 teig tei2 teig tei1 or tei2 teig tei1 field bits type value description reserved
c165h iom-2 interface controller data sheet 378 2001-04-19 p r e l i m i n a r y - exc er p t - command register address: s_adr_x + 0a h name: cmdr_x 15 141312111098 7 6 5 43210 rres reserved xres xme xtf reserved field bits type value description rres 15 w 0 receiver reset hdlc receiver is reset, the rfifo is cleared of any data. xres 7 w 0 transmitter reset hdlc transmitter is reset and the tfifo is cleared of any data. this command can be used by the microcontroller to abort a frame currently in transmission. xme 6 w 0 transmit message end by setting this bit to ? 1 ? the microcontroller indicates that the data word written last in the tfifo completes the corresponding frame. except in the extended transparent mode the transmission is terminated by appending the crc and the closing flag sequence to the data. xtf 5 w 0 transmit transparent frame the microcontroller initiates the transmission of a transparent frame by setting this bit to ? 1 ? . except in the extended transparent mode the opening flag is automatically added to the message. reserved 15 w these bits are reserved.
c165h iom-2 interface controller data sheet 379 2001-04-19 p r e l i m i n a r y - exc er pt - iom-2 channel selection note: the hdlc controller can transmit his data over any combination of the two 8-bit iom-2 channels and the two 2-bit iom-2 channels. note: the hdlc controller are priroritized with controller hdlc0 having the highest and hdlc3 the lowest priority. the iom-2 channel enabling (b1, b2, d1, d2) is exclusive, i.e. the controller with the higher priority will get the channel acces. the enabling flag of the controller with the lower priority will be reset. address: s_adr_x + 0c h name: iomsel_x 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 reserved en_d2 en_d1 en_b2 en_b1 field bits type value description en_d2 3 r/w 0 select second 2-bit iom-2 channel (d2) enable d2-channel (2-bit) for hdlc- controller access en_d1 2 r/w 0 select first 2-bit iom-2 channel (d1) enable d1-channel (2-bit) for hdlc- controller access en_b2 1 r/w 0 select second 8-bit iom-2 channel (b2) enable b2-channel (8-bit) for hdlc- controller access en_b1 0 r/w 0 select first 8-bit iom-2 channel (b1) enable b1-channel (8-bit) for hdlc- controller access reserved 15:7, 2:0 r these bits are reserved
c165h iom-2 interface controller data sheet 380 2001-04-19 p r e l i m i n a r y - exc er p t - mode register address: s_adr_x + 0e h name: modeh_x 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 rpe xpe res* sra x crc r crc res* itf mds res* rac res* = reserved field bits type value description mds 7:5 r/w 0 mode select determines the message transfer mode of the hdlc controller, as shown in table 72 . rac 3 r/w 0 receiver active the hdlc receiver is activated when this bit is set to ? 1 ? . if it is ? 0 ? the hdlc data is not evaluated in the receiver. itf 8 r/w 0 interframe time fill selects the inter-frame time fill signal which is transmitted between hdlc- frames. 0: idle (continuous ? 1 ? ) 1: flags (sequence of patterns: ? 0111 1110 ? ) note: itf must be set to ?0? for power down mode. in applications with d-channel access handling (collision resolution), the only possible inter- frame time fill is idle (continuous ?1?). otherwise the d-channel on the line interface can not be accessed rcrc 10 r/w 0 receive crc 0: crc is not stored in the rfifo (i.e. removed from incoming stream) 1: crc is stored in the rfifo
c165h iom-2 interface controller data sheet 381 2001-04-19 p r e l i m i n a r y - exc er pt - xcrc 11 r/w 0 transmit crc 0: crc is transmitted (i.e. generated) 1: crc is not transmitted sra 12 r/w 0 store receive address 0: receive address is not stored in the rfifo 1: receive address is stored in the rfifo xpe 14 r/w 0 transmit pec enable enables the xpr interrupt for hdlc channel 0: xpr interrupt disabled 1: xpr interrupt enabled rpe 15 r/w 0 receive pec enable enables the rpf interrupt for hdlc channel 0: rpf interrupt disabled 1: rpf interrupt enabled res* = reserved 13,9, 4, 2:0 r these bits are reserved. table 72 message transfer: mode select mds2-0 mode number of address bytes address comparison remark 1.byte 2.byte 0 0 0 reserved 0 0 1 reserved 0 1 0 non-auto mode 1tei1,tei2 ? one-byte address compare. 0 1 1 non-auto mode 2 sap1,sap2,sapg tei1,tei2,teig two-byte address compare. 1 0 0 extended transparent mode 1 1 0 transparent mode 0 ?? ? no address compare. all frames accepted. field bits type value description
c165h iom-2 interface controller data sheet 382 2001-04-19 p r e l i m i n a r y - exc er p t - note: sap1, sap2: two programmable address values for the first received address byte (in the case of an address field longer than 1 byte); sapg = fixed value fc / fe h . tei1, tei2: two programmable address values for the second (or the only, in the case of a one-byte address) received address byte; teig = fixed value ff h two different methods of the high byte and/or low byte address comparision can be selected by setting sap1.mha and/or sap2.ml sapi1 register 1 1 1 transparent mode 1 > 1 sap1,sap2,sapg ? high-byte address compare. 1 0 1 transparent mode 2 > 1 ? tei1,tei2,teig low-byte address compare. address: s_adr_x + 10 h name: sap1_x 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 reserved sapi1 res erv ed mha field bits type value description sapi1 7:2 w 3f h sapi1 value value of the first programmable service access point identifier (sapi) according to the isdn lapd protocol. table 72 message transfer: mode select (cont?d) mds2-0 mode number of address bytes address comparison remark 1.byte 2.byte
c165h iom-2 interface controller data sheet 383 2001-04-19 p r e l i m i n a r y - exc er pt - sapi2 register mha 0 w 0 mask high address 0: the sapi address of an incomming frame is compared with sap1, sap2, sapg 1: the sapi address of an incomming frame is compared with sap1 and sapg. sap1 can be masked with sap2 thereby bitpositions of sap1 are not compared if they are set to ? 1 ? in sap2. reserved 14:13 9,4 r these bits are reserved. address: s_adr_x + 12 h name: sap2_x 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 reserved sapi2 res erv ed mla field bits type value description sapi2 7:2 w 3f h sapi2 value value of the second programmable service access point identifier (sapi) according to the isdn lapd-protocol. field bits type value description
c165h iom-2 interface controller data sheet 384 2001-04-19 p r e l i m i n a r y - exc er p t - receive frame byte count mla 0 w 0 mask low address 0: the tei address of an incomming frame is compared with tei1, tei2, teig 1: the tei address of an incomming frame is compared with tei1 andteig. tei1 can be masked with tei2 thereby bitpositions of tei1 are not compared if they are set to ? 1 ? in tei2 reserved 14:13 9,4 r these bits are reserved. address: s_adr_x + 14 h name: rbc_x 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 reserved ov rbc field bits type value description
c165h iom-2 interface controller data sheet 385 2001-04-19 p r e l i m i n a r y - exc er pt - field bits type value description rbc 11:0 r/w 000 h 12 bits of the total number of bytes in a received message. bit 11 is the most significant bit, bit 0 the least significant bit, respective. note: normally rbc should be read by the microcontroller after an rme- interrupt in order to determine the number of bytes to be read from the rfifo, and the total message length. the contents of the registers are valid only after an rme or rpf interrupt, and remain so until the frame is acknowledged via resetting rbc (i.e. writing a value to rbc) or via resetting the rfifo (i.e. setting rres). ov 12 r/w 0 overflow a ? 1 ? in this bit position indicates a message longer than (2 12 - 1) = 4095 bytes . reserved 15:13 r these bits are reserved.
c165h iom-2 interface controller data sheet 386 2001-04-19 p r e l i m i n a r y - exc er p t - tei1 register address: s_adr_x + 16 h name: tei1_x 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 reserved tei1 ea field bits type value description tei1 7:1 w 7f h terminal endpoint identifier in all message transfer modes except in transparent modes 0, 1 and extended transparent mode, tei1 is used for address recognition. in the case of a two- byte address field, it contains the value of the first programmable terminal endpoint identifier according to the isdn lapd- protocol. in non-auto-modes with one-byte address field, tei1 is a command address, according to x.25 lapb. ea 0 w 1 address field extension bit this bit is set to ? 1 ? according to hdlc/ lapd. reserved 15:8 r these bits are reserved.
c165h iom-2 interface controller data sheet 387 2001-04-19 p r e l i m i n a r y - exc er pt - tei2 register address: s_adr_x + 18 h name: tei2_x 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 reserved tei1 ea field bits type value description tei1 7:1 w 7f h terminal endpoint identifier in all message transfer modes except in transparent modes 0, 1 and extended transparent mode, tei2 is used for address recognition. in the case of a two- byte address field, it contains the value of the second programmable terminal endpoint identifier according of the isdn lapd-protocol. in non-auto-modes with one-byte address field, tei2 is a response address, according to x.25 lapd. ea 0 w 1 address field extension bit this bit is to be set to ? 1 ? according to hdlc/lapd. reserved 15:8 r these bits are reserved.
c165h iom-2 interface controller data sheet 388 2001-04-19 p r e l i m i n a r y - exc er p t - looping register address: s_adr_x + 1a h name: loop_x 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 reserved elp fast tlp field bits type value description tlp 0 r/w 0 transmit loop setting tlp to ? 1 ? causes outgoing data being looped back into the receiver. the received data contains all hdlc procession, but does not contain the start and ending flag. fast 1 r/w 0 fast looping setting fast = ? 1 ? affects the tlp timing. ? 0 ? : the tlp is processed with the iom-2 lines condition (8 khz signal). ? 1 ? : the tlp looping runs with the bcl clock. elp 2 r/w 0 external loop setting elp to ? 1 ? causes incomming hdlc data being looped back to the line.
c165h watchdog timer (wdt) data sheet 389 2001-04-19 p r e l i m i n a r y - exc er pt - 15 watchdog timer (wdt) to allow recovery from software or hardware failure, the c165h provides a watchdog timer. if the software fails to service this timer before an overflow occurs, an internal reset sequence will be initiated. this internal reset will also pull the rstout pin low, which also resets the peripheral hardware, which might be the cause for the malfunction. when the watchdog timer is enabled and the software has been designed to service it regularly before it overflows, the watchdog timer will supervise the program execution, as it only will overflow if the program does not progress properly. the watchdog timer will also time out, if a software error was due to hardware related failures. this prevents the controller from malfunctioning for longer than a user-specified time. the watchdog timer provides two registers: a read-only timer register that contains the current count, and a control register for initialization. figure 125 sfrs and port pins associated with the watchdog timer the watchdog timer is a 16-bit up counter which can be clocked with the cpu clock ( f cpu ) either divided by 2 or divided by 128. this 16-bit timer is realized as two concatenated 8-bit timers (see figure below). the upper 8 bits of the watchdog timer can be preset to a user-programmable value via a watchdog service access in order to vary the watchdog expire time. the lower 8 bits are reset on each service access. figure 126 watchdog timer block diagram wdt wdtcon rstout reset indication pin data registers control registers mcb02052 wdt high byte wdtr mux 2 rstout wdtin wdt low byte wdtrel control wdt 128 f cpu reset clear
c165h watchdog timer (wdt) data sheet 390 2001-04-19 p r e l i m i n a r y - exc er p t - 15.1 operation of the watchdog timer the current count value of the watchdog timer is contained in the watchdog timer register wdt, which is a non-bitaddressable read-only register. the operation of the watchdog timer is controlled by its bitaddressable watchdog timer control register wdtcon. this register specifies the reload value for the high byte of the timer, selects the input clock prescaling factor and provides a flag that indicates a watchdog timer overflow. wdtcon (ffae h / d7 h ) sfr reset value: 00xx h the reset sources supported by the c165h are summarized in table 73 . note: differentiation between long and short hardware reset, known from other infineon c16x devices, is not supported. note: an internal power-on detection circuitry, also known from other c16x devices, is not implemented. therefore, bit wdtcon.5 (in other devices called ponr - power-on reset) is reserved. bit function wdtin watchdog timer input frequency selection ? 0 ? : input frequency is f cpu / 2 ? 1 ? : input frequency is f cpu / 128 wdtr watchdog timer reset indication flag set by the watchdog timer on an overflow. cleared by the srvwdt instruction. swr software reset set by the command srst shwr short hardware reset set by the input rstin note : the c165h does not distinguish between short and long hardware reset. lhwr long hardware reset set by the input rstin reserved reserved these bits are reserved wdtrel watchdog timer reload value (for the high byte) shw r wdt r swr wdt in lhw r 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 r rw - - wdtrel rw r r r - reserved
c165h watchdog timer (wdt) data sheet 391 2001-04-19 p r e l i m i n a r y - exc er pt - note: the wdtcon register bits [7, 6, 5] 4, 3, 2 and 1 are cleared by the einit command. after any software reset, external hardware reset, or watchdog timer reset, the watchdog timer is enabled and starts counting up from 0000 h with the frequency f cpu /2. the input frequency may be switched to f cpu /128 by setting bit wdtin. the watchdog timer can be disabled via the instruction diswdt (disable watchdog timer). instruction diswdt is a protected 32-bit instruction which will only be executed during the time between a reset and execution of either the einit (end of initialization) or the srvwdt (service watchdog timer) instruction. either one of these instructions disables the execution of diswdt. when the watchdog timer is not disabled via instruction diswdt, it will continue counting up, even during idle mode. if it is not serviced via the instruction srvwdt by the time the count reaches ffff h the watchdog timer will overflow and cause an internal reset. this reset will pull the external reset indication pin rstout low. it differs from a software or external hardware reset in that bit wdtr (watchdog timer reset indication flag) of register wdtcon will be set. a hardware reset or the srvwdt instruction will clear this bit. bit wdtr can be examined by software in order to determine the cause of the reset. a watchdog reset will also complete a running external bus cycle before starting the internal reset sequence if this bus cycle does not use ready or samples ready active (low) after the programmed waitstates. otherwise the external bus cycle will be aborted. note: after a hardware reset that activates the bootstrap loader the watchdog timer will be disabled. to prevent the watchdog timer from overflowing, it must be serviced periodically by the user software. the watchdog timer is serviced with the instruction srvwdt, which is a protected 32-bit instruction. servicing the watchdog timer clears the low byte and reloads the high byte of the watchdog timer register wdt with the preset value from bitfield wdtrel which is the high byte of register wdtcon. servicing the watchdog timer will also reset bit wdtr. after being serviced the watchdog timer continues counting up from the value ( * 2 8 ). instruction srvwdt has been encoded in such a way that the chance of unintentionally servicing the watchdog timer (eg. by fetching and executing a bit pattern from a wrong location) is minimized. when instruction srvwdt does not table 73 wdtcon register: reset source identification type of reset wdtcon reset value wdtcon flags being set hardware reset via pin rstin 001c h lhwr, shwr, swr software reset via command srst 0004 h swr watchdog timer reset 0006 h swr, wdtr
c165h watchdog timer (wdt) data sheet 392 2001-04-19 p r e l i m i n a r y - exc er p t - match the format for protected instructions the protection fault trap will be entered, rather than the instruction be executed. the time period for an overflow of the watchdog timer is programmable in two ways:  the input frequency to the watchdog timer can be selected via bit wdtin in register wdtcon to be either f cpu /2 or f cpu /128.  the reload value wdtrel for the high byte of wdt can be programmed in register wdtcon. the period p wdt between servicing the watchdog timer and the next overflow can therefore be determined by the following formula: note: for safety reasons, the user is advised to rewrite wdtcon each time before the watchdog timer is serviced. p wdt = f cpu 2 (1 + *6) * (2 16 - * 2 8 )
c165h bootstrap loader data sheet 393 2001-04-19 p r e l i m i n a r y - exc er pt - 16 bootstrap loader the built-in bootstrap loader of the c165h provides a mechanism to load the startup program, which is executed after reset, via the serial interface. the bootstrap loader moves code/data into the internal ram, but it is also possible to transfer data via the serial interface into an external ram using a second level loader routine. it may be used to provide lookup tables or may provide ?core-code?, ie. a set of general purpose subroutines, eg. for i/o operations, number crunching, system initialization, etc. figure 127 bootstrap loader sequence the bootstrap loader may be used to load the complete application software into romless systems, it may load temporary software into complete systems for testing or calibration. the bsl mechanism may be used for standard system startup as well as only for special occasions like system maintenance (firmware update) or end-of-line programming or testing. rstin txd0 int. boot rom bsl-routine 32 bytes 2) 3) rxd0 csp:ip user software 4) 6) p0l.4 1) bsl initialization time, > 2 s @ f cpu = 20 mhz. 2) zero byte (1 start bit, eight ?0? data bits, 1 stop bit), sent by host. 3) identification byte, sent by c165h. 4) 32 bytes of code / data, sent by host. 1) 5)
c165h bootstrap loader data sheet 394 2001-04-19 p r e l i m i n a r y - exc er p t - entering the bootstrap loader the c165h enters bsl mode if pin p0l.4 is sampled low at the end of a hardware reset. in this case the built-in bootstrap loader is activated independent of the selected bus mode. after entering bsl mode and the respective initialization the c165h scans the rxd0 line to receive a zero byte, ie. one start bit, eight ?0? data bits and one stop bit. from the duration of this zero byte it calculates the corresponding baudrate factor with respect to the current cpu clock, initializes the serial interface asc accordingly and switches pin txd0 to output. using this baudrate, an identification byte is returned to the host that provides the loaded data. this identification byte identifies the device to be booted. the following codes are defined for infineon technologies microcontrollers: 55 h : 8xc166. a5 h : previous versions of the c167 (obsolete). b5 h : c165. c5 h : c167 derivatives. d5 h : c165h (and all other devices equipped with identification registers). note: the identification byte d5 h does not directly identify a specific derivative. this information can in this case be obtained from the identification registers. when the c165h has entered bsl mode, the following configuration is automatically set (values that deviate from the normal reset values, are marked ): watchdog timer: disabled register syscon: 0e00 h context pointer cp: fa00 h register stkun: fa40 h stack pointer sp: fa40 h register stkov: fa0c h 0<->c register s0con: 8011 h register buscon0: acc. to startup config. register s0bg: acc. to ?00? byte p3.10 / txd0: ? 1 ? dp3.10: ? 1 ? other than after a normal reset the watchdog timer is disabled, so the bootstrap loading sequence is not time limited. pin txd0 is configured as output, so the c165h can return the identification byte. the hardware that activates the bsl during reset may be a simple pull-down resistor on p0l.4 for systems that use this feature upon every hardware reset. you may want to use a switchable solution (via jumper or an external signal) for systems that only temporarily use the bootstrap loader.
c165h bootstrap loader data sheet 395 2001-04-19 p r e l i m i n a r y - exc er pt - figure 128 hardware provisions to activate the bsl after sending the identification byte the asc receiver is enabled and is ready to receive the initial 32 bytes from the host. a half duplex connection is therefore sufficient to feed the bsl. note: in order to properly enter bsl mode it is not only required to pull p0l.4 low, but also pins p0l.2, p0l.3, p0l.5 must receive defined levels. this is described in chapter "system reset?. loading the startup code after sending the identification byte the bsl enters a loop to receive 32 bytes via asc. these bytes are stored sequentially into locations 00?fa40 h through 00?fa5f h of the internal ram. so up to 16 instructions may be placed into the ram area. to execute the loaded code the bsl then jumps to location 00?fa40 h , ie. the first loaded instruction. the bootstrap loading sequence is now terminated, the c165h remains in bsl mode, however. most probably the initially loaded routine will load additional code or data, as an average application is likely to require substantially more than 16 instructions. this second receive loop may directly use the pre-initialized interface asc to receive data and store it to arbitrary user-defined locations. this second level of loaded code may be the final application code. it may also be another, more sophisticated, loader routine that adds a transmission protocol to enhance the integrity of the loaded code or data. it may also contain a code sequence to change the system configuration and enable the bus interface to store the received data into external memory. this process may go through several iterations or may directly execute the final application. in all cases the c165h will still run in bsl mode, ie. with the watchdog timer disabled and limited access to the internal code memory. mca02261 p0l.4 ? circuit_1 p0l.4 r 8 k p0l.4 external signal r bsl 8 k p0l.4 ? normal boot circuit_2
c165h bootstrap loader data sheet 396 2001-04-19 p r e l i m i n a r y - exc er p t - exiting bootstrap loader mode in order to execute a program in normal mode, the bsl mode must be terminated first. the c165h exits bsl mode upon a software reset (ignores the level on p0l.4) or a hardware reset (p0l.4 must be high then!). after a reset the c165h will start executing from location 00?0000 h of the external memory (make sure, pin ea is tied to ?0? signal). choosing the baudrate for the bsl the calculation of the serial baudrate for asc from the length of the first zero byte that is received, allows the operation of the bootstrap loader of the c165h with a wide range of baudrates. however, the upper and lower limits have to be kept, in order to insure proper data transfer. the c165h uses timer t6 to measure the length of the initial zero byte. the quantization uncertainty of this measurement implies the first deviation from the real baudrate, the next deviation is implied by the computation of the s0brl reload value from the timer contents. the formula below shows the association: for a correct data transfer from the host to the c165h the maximum deviation between the internal initialized baudrate for asc and the real baudrate of the host should be below 2.5%. the deviation (f b , in percent) between host baudrate and c165h baudrate can be calculated via the formula below: note: f unction (f b ) does not consider the tolerances of oscillators and other devices supporting the serial communication. this baudrate deviation is a nonlinear function depending on the cpu clock and the baudrate of the host. the maxima of the function (f b ) increase with the host baudrate due to the smaller baudrate prescaler factors and the implied higher quantization error (see figure below). f cpu 32 s0brl 1 + () ? ------------------------------------------ - b c165h s0brl t6 36 ? 72 ------------------ - = t6 9 4 -- f cpu b host --------------- ? = , f b b contr b host ? b contr --------------------------------------- - 100 ? = % f b 2,5 % ,
c165h bootstrap loader data sheet 397 2001-04-19 p r e l i m i n a r y - exc er pt - figure 129 baudrate deviation between host and c165h minimum baudrate (b low in the figure above) is determined by the maximum count capacity of timer t6, when measuring the zero byte, ie. it depends on the cpu clock. using the maximum t6 count 2 16 in the formula the minimum baudrate for f cpu =20 mhz is 687 baud. the lowest standard baudrate in this case would be 1200 baud. baudrates below b low would cause t6 to overflow. in this case asc cannot be initialized properly. maximum baudrate (b high in the figure above) is the highest baudrate where the deviation still does not exceed the limit, ie. all baudrates between b low and b high are below the deviation limit. the maximum standard baudrate that fulfills this requirement is 19200 baud. higher baudrates , however, may be used as long as the actual deviation does not exceed the limit. a certain baudrate (marked i) in the figure) may eg. violate the deviation limit, while an even higher baudrate (marked ii) in the figure) stays very well below it. this depends on the host interface. mca02260 b f 2.5% low b b high ? b host
c165h system reset data sheet 398 2001-04-19 p r e l i m i n a r y - exc er p t - 17 system reset the internal system reset function provides initialization of the c165h into a defined default state and is invoked either by asserting a hardware reset signal on pin rstin (hardware reset input), upon the execution of the srst instruction (software reset) or by an overflow of the watchdog timer (wdt). whenever one of these conditions occurs, the microcontroller is reset into its predefined default state through an internal reset procedure. when a reset is initiated, pending internal hold states are cancelled and the current internal access cycle (if any) is completed. an external bus cycle is aborted, except for a watchdog reset (see description). after that the bus pin drivers and the i/o pin drivers are switched off (tristate). rstout is activated depending on the reset source. the internal reset procedure requires 516 cpu clock cycles in order to perform a complete reset sequence. this 516 cycle reset sequence is started upon a watchdog timer overflow, a srst instruction or when the reset input signal rstin is latched low (hardware reset). the internal reset condition is active at least for the duration of the reset sequence and then until the rstin input is inactive. when this internal reset condition is removed (reset sequence complete and rstin inactive), the reset configuration is latched from port0, and pins ale, rd and wr are driven to their inactive levels. note: bit adp, which selects the adapt mode during low rstin signal, is latched with the rising edge of rstin . after the internal reset condition is removed, the microcontroller will start program execution from memory location 00?0000 h in code segment zero. this start location will typically hold a branch instruction to the start of a software initialization routine for the application specific configuration of peripherals and cpu special function registers.
c165h system reset data sheet 399 2001-04-19 p r e l i m i n a r y - exc er pt - figure 130 external reset circuitry hardware reset a hardware reset is triggered when the reset input signal rstin is latched low. to ensure the recognition of the rstin signal (latching), it must be held low for at least 8 cpu clock cycles. note: during reset, the cpu is clocked with the free-running pll clock which may run as slow as < 1 mhz. also shorter rstin pulses may trigger a hardware reset, if they coincide with the latch?s sample point. however, it is recommended to keep rstin low for ca. 1 ms. after the reset sequence has been completed, the rstin input is sampled. when the reset input signal is active at that time the internal reset condition is prolonged until rstin gets inactive. during a hardware reset the port0 inputs for the reset configuration need some time to settle on the required levels, especially if the hardware reset aborts a read operation form an external peripheral. during this settling time the configuration may intermittently be wrong. in such a case also the pll clock selection may be wrong. note: to ensure a glitch free start-up of the c165h, it is strongly recommended to provide an external reset pulse of ca. 1 ms in order to allow the pll to settle on the desired cpu clock frequency. the input rstin provides an internal pullup device equalling a resistor of 100 k ? to 660 k ? (the minimum reset time must be determined by the lowest value). simply connecting an external capacitor is sufficient for an automatic power-on reset, see b) in reset + a) generated warm reset b) automatic power-on reset & mca04934 rstout c165h external hardware a) b) external reset sources cc v rstin
c165h system reset data sheet 400 2001-04-19 p r e l i m i n a r y - exc er p t - figure 130 . rstin may also be connected to the output of other logic gates, see a) same figure. note: a power-on reset requires an active time of two reset sequences (1036 cpu clock cycles) after a stable clock signal is available (about 10...50 ms to allow the on- chip oscillator to stabilize). software reset the reset sequence can be triggered at any time via the protected instruction srst (software reset). this instruction can be executed deliberately within a program, eg. to leave bootstrap loader mode, or upon a hardware trap that reveals a system failure. c165h?s latched in reset configuration on software reset is shown in figure 132 , page 406. watchdog timer reset when the watchdog timer is not disabled during the initialization or serviced regularly during program execution it will overflow and trigger the reset sequence. other than hardware and software reset the watchdog reset completes a running external bus cycle if this bus cycle either does not use ready at all, or if ready is sampled active (low) after the programmed waitstates. when ready is sampled inactive (high) after the programmed waitstates the running external bus cycle is aborted. then the internal reset sequence is started. note: for latched in watchdog reset configuration, refer to figure 132 , page 406. the watchdog reset cannot occur while the c165h is in bootstrap loader mode! the c165h?s pins after reset after the reset sequence the different groups of pins of the c165h are activated in different ways depending on their function. bus and control signals are activated immediately after the reset sequence according to the configuration latched from port0, so either external accesses can take place or the external control signals are inactive. the general purpose i/o pins remain in input mode (high impedance) until reprogrammed via software (see figure below). the rstout pin remains active (low) until the end of the initialization routine (see description).
c165h system reset data sheet 401 2001-04-19 p r e l i m i n a r y - exc er pt - figure 131 reset input and output signals reset output pin the rstout pin is dedicated to generate a reset signal for the system components besides the controller itself. rstout will be driven active (low) at the begin of any reset sequence (triggered by hardware, the srst instruction or a watchdog timer overflow). rstout stays active (low) beyond the end of the internal reset sequence until the protected einit (end of initialization) instruction is executed (see figure above). this delayed until the end of the internal reset condition. current bus cycle is completed or aborted. activation of the io pins is controlled by software. execution of the einit instruction. when the internal reset condition is extended by rstin, the activation of the output signals is switches asinchronously with rstin, sinchronously upon software or watchdog reset. the reset condition ends here. the c 167cr starts program execution. the shaded area designates the internal reset sequence, which starts after synchronization of rstin. rstin internal reset condition 6) initialization 3) mcs02258 rd, wr rstout io ale bus rstin internal reset condition 6) 1) 2) 2) initialization 3) 5) 4) 8) 7) a short hardware reset is extended until the end of the reset sequence in bidirectional reset mode. a software or wdt reset activates the rstin line in bidirectional reset mode. 8) 7) 6) 3) 2) 5) 4) 1)
c165h system reset data sheet 402 2001-04-19 p r e l i m i n a r y - exc er p t - allows the complete configuration of the controller including its on-chip peripheral units before releasing the reset signal for the external peripherals of the system. watchdog timer operation after reset the watchdog timer starts running after the internal reset has completed. it will be clocked with the internal system clock divided by 2 (18 mhz @ f cpu =36 mhz), and its default reload value is 00 h , so a watchdog timer overflow will occur 131072 cpu clock cycles (3.64 ms @ f cpu =36 mhz) after completion of the internal reset, unless it is disabled, serviced or reprogrammed meanwhile. when the system reset was caused by a watchdog timer overflow, the wdtr (watchdog timer reset indication) flag in register wdtcon will be set to '1'. this indicates the cause of the internal reset to the software initialization routine. wdtr is reset to '0' by an external hardware reset or by servicing the watchdog timer. after the internal reset has completed, the operation of the watchdog timer can be disabled by the diswdt (disable watchdog timer) instruction. this instruction has been implemented as a protected instruction. for further security, its execution is only enabled in the time period after a reset until either the srvwdt (service watchdog timer) or the einit instruction has been executed. thereafter the diswdt instruction will have no effect. note: for a complete description of register wdtcon, refer to chapter 15.1 , page 390. reset values for the c165h registers during the reset sequence the registers of the c165h are preset with a default value. most sfrs, including system registers and peripheral control and data registers, are cleared to zero, so all peripherals and the interrupt system are off or idle after reset. a few exceptions to this rule provide a first pre-initialization, which is either fixed or controlled by input pins. dpp1: 0001 h (points to data page 1) dpp2: 0002 h (points to data page 2) dpp3: 0003 h (points to data page 3) cp: fc00 h stkun: fc00 h stkov: fa00 h sp: fc00 h wdtcon: 00xx h , (value depends on the reset configuration) s0rbuf: xx h (undefined) sscrb: xxxx h (undefined) syscon: 0xx0 h (set according to reset configuration) buscon0: 0xx0 h (set according to reset configuration) rp0h: xx h (reset levels of p0h) ones: ffff h (fixed value)
c165h system reset data sheet 403 2001-04-19 p r e l i m i n a r y - exc er pt - the internal ram after reset the contents of the internal ram are not affected by a system reset. however, after power-on the contents of the internal ram are undefined. this implies that the gprs (r15...r0) and the pec source and destination pointers (srcp7...srcp0, dstp7...dstp0) which are mapped into the internal ram are also unchanged after a hardware reset, software reset or watchdog reset, but are undefined after power-on. ports and external bus configuration during reset during the internal reset sequence all of the c165h's port pins are configured as inputs by clearing the associated direction registers, and their pin drivers are switched to the high impedance state. this ensures that the c165h and external devices will not try to drive the same pin to different levels. pin ale is held low through an internal pulldown, and pins rd and wr are held high through internal pullups. also the pins selected for cs output will be pulled high. the registers syscon and buscon0 are initialized according to the configuration selected via port0:  the bus type field (btyp) in register buscon0 is initialized according to p0l.7 and p0l.6  bit busact0 in register buscon0 is set to ?1?  bit alectl0 in register buscon0 is set to ?1?  bit romen in register syscon will be cleared to ?0?  bit bytdis in register syscon is set according to the data bus width note: in the c165h, pin ea must always be set to ?0?. the "internal start" (ea =?1?), known from other infineon c16x devices is not supported. the other bits of register buscon0, and the other buscon registers are cleared. this default initialization selects the slowest possible external accesses using the configured bus type. the ready function is disabled at the end of the internal system reset. when the internal reset has completed, the configuration of port0, port1, port 4, port 6 and of the bhe signal (high byte enable, alternate function of p3.12) depends on the bus type which was selected during reset. when any of the external bus modes was selected during reset, port0 (and port1) will operate in the selected bus mode. port 4 will output the selected number of segment address lines (all zero after reset) and port 6 will drive the selected number of cs lines (cs0 will be ?0?, while the other active cs lines will be ?1?). when no memory accesses above 64 k are to be performed, segmentation may be disabled. when the on-chip bootstrap loader was activated during reset, pin txd0 (alternate function of p3.10) will be switched to output mode after the reception of the zero byte. all other pins remain in the high-impedance state until they are changed by software or peripheral operation.
c165h system reset data sheet 404 2001-04-19 p r e l i m i n a r y - exc er p t - application-specific initialization routine after the internal reset condition is removed the c165h fetches the first instruction from location 00?0000 h , which is the first vector in the trap/interrupt vector table, the reset vector. 4 words (locations 00?0000 h through 00?0007 h ) are provided in this table to start the initialization after reset. as a rule, this location holds a branch instruction to the actual initialization routine that may be located anywhere in the address space. note: when the bootstrap loader mode was activated during a hardware reset the c165h does not fetch instructions from location 00?0000 h but rather expects data via serial interface asc. the first instruction is fetched from external memory. to decrease the number of instructions required to initialize the c165h, each peripheral is programmed to a default configuration upon reset, but is disabled from operation. these default configurations can be found in the descriptions of the individual peripherals. during the software design phase, portions of the internal memory space must be assigned to register banks and system stack. when initializating the stack pointer (sp) and the context pointer (cp), it must be ensured that these registers are initialized before any gpr or stack operation is performed. this includes interrupt processing, which is disabled upon completion of the internal reset, and should remain disabled until the sp is initialized. note: traps (incl. nmi ) may occur, even though the interrupt system is still disabled. in addition, the stack overflow (stkov) and the stack underflow (stkun) registers should be initialized. after reset, the cp, sp, and stkun registers all contain the same reset value 00?fc00 h , while the stkov register contains 00?fa00 h . with the default reset initialization, 256 words of system stack are available, where the system stack selected by the sp grows downwards from 00?fbfe h , while the register bank selected by the cp grows upwards from 00?fc00 h . based on the application, the user may wish to initialize portions of the internal memory before normal program operation. once the register bank has been selected by programming the cp register, the desired portions of the internal memory can easily be initialized via indirect addressing. at the end of the initialization, the interrupt system may be globally enabled by setting bit ien in register psw. care must be taken not to enable the interrupt system before the initialization is complete. the software initialization routine should be terminated with the einit instruction. this instruction has been implemented as a protected instruction. execution of the einit instruction...  disables the action of the diswdt instruction,  disables write accesses to register syscon,
c165h system reset data sheet 405 2001-04-19 p r e l i m i n a r y - exc er pt - note : all configurations regarding register syscon (enable clkout, stacksize, etc.) must be selected before the execution of einit.  disables write access to registers syscon2 and syscon3 (further write accesses to syscon2 and syscon3 can be executed only using a special unlock mechanism),  clears the reset source detection bits in register wdtcon,  causes the rstout pin to go high. this signal can be used to indicate the end of the initialization routine and the proper operation of the microcontroller to external hardware. 17.1 system startup configuration although most of the programmable features of the c165h are either selected during the initialization phase or repeatedly during program execution, there are some features that must be selected earlier, because they are used for the first access of the program execution. these selections are made during reset via the pins of port0, which are read at the end of the internal reset sequence. during reset internal pullup devices are active on the port0 lines, so their input level is high, if the respective pin is left open, or is low, if the respective pin is connected to an external pulldown device. with the coding of the selections, as shown below, in many cases the default option, ie. high level, can be used. the value on the upper byte of port0 (p0h) is latched into register rp0h upon reset, the value on the lower byte (p0l) directly influences the buscon0 register (bus mode) or the internal control logic of the c165h.
c165h system reset data sheet 406 2001-04-19 p r e l i m i n a r y - exc er p t - figure 132 port0 configuration during reset note: the configuration on pins p0h.7:p0h.5 (clkcfg) and p0l5:p0l.2 (smod) is latched in on a hardware triggered reset only and will not be evaluated by the c165h on a software and/or wdt reset. the configuration via p0h is latched in register rp0h for subsequent evaluation by software. register rp0h is described in chapter ?the external bus interface?. note: the reset configuration needs to be held on port p0 throughout the start-up phase until the c165h takes over control of the external xbus. this is first indicated by driving the xbus output lines ale, rd , wr /wrl , cs , p4, p1h and p1l. since it might prove infeasible to detect the change from tristate to a strongly driven value, the first rising edge of ale can be used for indication of the end of the reset configuration hold time. the first rising edge of ale occurs 4 cpu cycles after taking control of the external bus. the following describes the different selections that are offered for reset configuration. the default modes refer to pins at high level, ie. without external pulldown devices connected. table 74 shows a summary of all modes, supported by the c165h. note: the emulation mode, known from other c16x infineon devices, is not supported by the c165h. make sure, on pin p0l.0 a high signal is always latched in. high ?1? adp wrc l.5 l.4 l.3 l.2 l.1 l.0 h.3 h.2 h.1 h.0 l.7 l.6 h.7 h.6 h.5 h.4 cssel salsel bustyp rp0h port 4 logic port 6 logic syscon buscon0 internal control logic clkcfg clock generator smod p0l.0 must be ? 1 ? always l.5 l.4 l.3 l.2 l.1 l.0 h.3 h.2 h.1 h.0 l.7 l.6 h.7 h.6 h.5 h.4 l.1 l.0 h.3 h.2 h.1 h.0 l.7 l.6 h.4 configuration latched in on hardware reset configuration latched in on software and/or wdt reset
c165h system reset data sheet 407 2001-04-19 p r e l i m i n a r y - exc er pt - on p0l.0 is the default configuration and is supported by the internal pull-up device. adapt mode pin p0l.1 (adp) selects the adapt mode when low during reset. it is latched with the rising edge of rstin . in this mode, the c165h goes into a passive state, which is similar to its state during reset. the pins of the c165h float to tristate or are deactivated via internal pullup/pulldown devices, as described for the reset state. in addition also the rstout pin floats to tristate rather than be driven low, and the on-chip oscillator is switched off. this mode allows switching a c165h that is mounted to a board virtually off, so an emulator may control the board?s circuitry, even though the original c165h remains in its place. the original c165h also may resume to control the board after a reset sequence with p0l.1 high. default: adapt mode is off. bootstrap loader mode pin p0l.4 (bsl) activates the on-chip bootstrap loader, when low during reset. the bootstrap loader allows moving the start code into the internal ram of the c165h via the serial interface asc. the c165h will remain in bootstrap loader mode until a hardware reset with p0l.4 high or a software reset. default: the c165h starts fetching code from location 00?0000 h , the bootstrap loader is off. external bus type pins p0l.7 and p0l.6 (bustyp) select the external bus type during reset, if an external start is selected via pin ea . this allows the configuration of the external bus interface of the c165h even for the first code fetch after reset. the two bits are copied into bit field btyp of register buscon0. p0l.7 controls the data bus width, while p0l.6 controls the table 74 c165h?s supported modes and related reset configurations p0l.5 : p0l.2 (smod) p0l.1 (adp) selected mode x x x x 0 adapt mode 1 1 1 1 1 normal mode 0 0 0 1 1 internal boot-rom read-out 1 0 1 1 1 bootstrap-loader mode 1 1 0 1 1 selftest
c165h system reset data sheet 408 2001-04-19 p r e l i m i n a r y - exc er p t - address output (multiplexed or demultiplexed). this bit field may be changed via software after reset, if required. port0 and port1 are automatically switched to the selected bus mode. in multiplexed bus modes port0 drives both the 16-bit intra-segment address and the output data, while port1 remains in high impedance state as long as no demultiplexed bus is selected via one of the buscon registers. in demultiplexed bus modes port1 drives the 16-bit intra-segment address, while port0 or p0l (according to the selected data bus width) drives the output data. for a 16-bit data bus bhe is automatically enabled, for an 8-bit data bus bhe is disabled via bit bytdis in register syscon. default: 16-bit data bus with multiplexed addresses. note: if an internal start is selected via pin ea , these two pins are disregarded and bit field btyp of register buscon0 is cleared. write configuration pin p0h.0 (wrc) selects the initial operation of the control pins wr and bhe during reset. when high, this pin selects the standard function, ie. wr control and bhe . when low, it selects the alternate configuration, ie. wrh and wrl . thus even the first access after a reset can go to a memory controlled via wrh and wrl . this bit is latched in register rp0h and its inverted value is copied into bit wrcfg in register syscon. default: standard function (wr control and bhe ). chip select lines pins p0h.2 and p0h.1 (cssel) define the number of active chip select signals during reset. this allows the selection which pins of port 6 drive external cs signals and which are used for general purpose io. the two bits are latched in register rp0h. default: all 5 chip select lines active (cs4 ...cs0 ). btyp encoding external data bus width external address bus mode 0 0 8-bit data demultiplexed addresses 0 1 8-bit data multiplexed addresses 1 0 16-bit data demultiplexed addresses 1 1 16-bit data multiplexed addresses cssel chip select lines note 1 1 five: cs4 ...cs0 default without pull-downs 1 0 none port 6 pins free for i/o
c165h system reset data sheet 409 2001-04-19 p r e l i m i n a r y - exc er pt - note: the selected number of cs signals cannot be changed via software after reset. segment address lines pins p0h.4 and p0h.3 (salsel) define the number of active segment address lines during reset. this allows the selection which pins of port 4 drive address lines and which are used for general purpose io. the two bits are latched in register rp0h. depending on the system architecture the required address space is chosen and accessible right from the start, so the initialization routine can directly access all locations without prior programming. the required pins of port 4 are automatically switched to address output mode. even if not all segment address lines are enabled on port 4, the c165h internally uses its complete 24-bit addressing mechanism. this allows the restriction of the width of the effective address bus, while still deriving cs signals from the complete addresses. default: 2-bit segment address (a17...a16) allowing access to 256 kbyte. note: the selected number of segment address lines cannot be changed via software after reset. clock generation control pins p0h.7, p0h.6 and p0h.5 (clkcfg) select the clock generation mode (on-chip pll) during reset. please refer to chapter 3.3, "clock generation concept". 0 1 two: cs1 ...cs0 p6.4..p6.2 free for gpi/o 0 0 three: cs2 ...cs0 p6.4..p6.3 free for gpi/o salsel segment address lines directly accessible address space 1 1 two: a17...a16 256 kbyte (default without pull-downs) 1 0 eight: a22...a16 8 mbyte (maximum) 0 1 none 64 kbyte (minimum) 0 0 four: a19...a16 1 mbyte cssel chip select lines note
c165h power reduction modes data sheet 410 2001-04-19 p r e l i m i n a r y - exc er p t - 18 power reduction modes two different power reduction modes with different levels of power reduction have been implemented in the c165h, which may be entered under software control. in idle mode the cpu is stopped, while the peripherals continue their operation. idle mode can be terminated by any reset or interrupt request. in power down mode both the cpu and the peripherals are stopped. power down mode can only be terminated by a hardware reset. note: all external bus actions are completed before idle or power down mode is entered. however, idle or power down mode is not entered if ready is enabled, but has not been activated (driven low) during the last bus access. 18.1 idle mode the power consumption of the c165h microcontroller can be decreased by entering idle mode. in this mode all peripherals, including the watchdog timer, continue to operate normally, only the cpu operation is halted. idle mode is entered after the idle instruction has been executed and the instruction before the idle instruction has been completed. to prevent unintentional entry into idle mode, the idle instruction has been implemented as a protected 32-bit instruction. idle mode is terminated by interrupt requests from any enabled interrupt source whose individual interrupt enable flag was set before the idle mode was entered, regardless of bit ien. for a request selected for cpu interrupt service the associated interrupt service routine is entered if the priority level of the requesting source is higher than the current cpu priority and the interrupt system is globally enabled. after the reti (return from interrupt) instruction of the interrupt service routine is executed the cpu continues executing the program with the instruction following the idle instruction. otherwise, if the interrupt request cannot be serviced because of a too low priority or a globally disabled interrupt system the cpu immediately resumes normal program execution with the instruction following the idle instruction. for a request which was programmed for pec service a pec data transfer is performed if the priority level of this request is higher than the current cpu priority and the interrupt system is globally enabled. after the pec data transfer has been completed the cpu remains in idle mode. otherwise, if the pec request cannot be serviced because of a too low priority or a globally disabled interrupt system the cpu does not remain in idle mode but continues program execution with the instruction following the idle instruction.
c165h power reduction modes data sheet 411 2001-04-19 p r e l i m i n a r y - exc er pt - figure 133 transitions between idle mode and active mode idle mode can also be terminated by a non-maskable interrupt, ie. a high to low transition on the nmi pin. after idle mode has been terminated by an interrupt or nmi request, the interrupt system performs a round of prioritization to determine the highest priority request. in the case of an nmi request, the nmi trap will always be entered. any interrupt request whose individual interrupt enable flag was set before idle mode was entered will terminate idle mode regardless of the current cpu priority. the cpu will not go back into idle mode when a cpu interrupt request is detected, even when the interrupt was not serviced because of a higher cpu priority or a globally disabled interrupt system (ien=?0?). the cpu will only go back into idle mode when the interrupt system is globally enabled (ien=?1?) and a pec service on a priority level higher than the current cpu level is requested and executed. note: an interrupt request which is individually enabled and assigned to priority level 0 will terminate idle mode. the associated interrupt vector will not be accessed, however. the watchdog timer may be used to monitor the idle mode: an internal reset will be generated if no interrupt or nmi request occurs before the watchdog timer overflows. to prevent the watchdog timer from overflowing during idle mode it must be programmed to a reasonable time interval before idle mode is entered. the standard idle mode can be additionally configured by programming the syscon3 register, using the flexible peripheral management functions. this is especially advantages, because it is thus possible to activate only these peripherals also in idle mode which are really required for standby operation or for wakeup, reducing power consumption to the absolute minimum for a specific peripheral operation during idle mode. active mode idle mode idle instruction cpu interrupt request denied pec request executed pec request denied accepted
c165h power reduction modes data sheet 412 2001-04-19 p r e l i m i n a r y - exc er p t - 18.2 power down mode to further reduce the power consumption the microcontroller can be switched to power down mode. clocking of all internal blocks is stopped, the contents of the internal ram, however, are preserved through the voltage supplied via the v cc pins. the watchdog timer is stopped in power down mode. this mode can only be terminated by an external hardware reset, ie. by asserting a low level on the rstin pin. this reset will initialize all sfrs and ports to their default state, but will not change the contents of the internal ram. there are two levels of protection against unintentionally entering power down mode. first, the pwrdn (power down) instruction which is used to enter this mode has been implemented as a protected 32-bit instruction. second, this instruction is effective only if the nmi (non maskable interrupt) pin is externally pulled low while the pwrdn instruction is executed. the microcontroller will enter power down mode after the pwrdn instruction has completed. this feature can be used in conjunction with an external power failure signal which pulls the nmi pin low when a power failure is imminent. the microcontroller will enter the nmi trap routine which can save the internal state into ram. after the internal state has been saved, the trap routine may set a flag or write a certain bit pattern into specific ram locations, and then execute the pwrdn instruction. if the nmi pin is still low at this time, power down mode will be entered, otherwise program execution continues. during power down the voltage at the v cc pins can be lowered to 2.5 v while the contents of the internal ram will still be preserved. the initialization routine (executed upon reset) can check the identification flag or bit pattern within ram to determine whether the controller was initially switched on, or whether it was properly restarted from power down mode. 18.3 status of output pins during idle and power down mode during idle mode the cpu clocks are turned off, while all peripherals continue their operation in the normal way. therefore all ports pins, which are configured as general purpose output pins, output the last data value which was written to their port output latches. if the alternate output function of a port pin is used by a peripheral, the state of the pin is determined by the operation of the peripheral. port pins which are used for bus control functions go into that state which represents the inactive state of the respective function (eg. wr ), or to a defined state which is based on the last bus access (eg. bhe ). port pins which are used as external address/data bus hold the address/data which was output during the last external memory access before entry into idle mode under the following conditions: p0h outputs the high byte of the last address if a multiplexed bus mode with 8-bit data bus is used, otherwise p0h is floating. p0l is always floating in idle mode.
c165h power reduction modes data sheet 413 2001-04-19 p r e l i m i n a r y - exc er pt - port1 outputs the lower 16 bits of the last address if a demultiplexed bus mode is used, otherwise the output pins of port1 represent the port latch data. port 4 outputs the segment address for the last access on those pins that were selected during reset, otherwise the output pins of port 4 represent the port latch data. during power down mode the oscillator and the clocks to the cpu and to the peripherals are turned off. like in idle mode, all port pins which are configured as general purpose output pins output the last data value which was written to their port output latches. when the alternate output function of a port pin is used by a peripheral the state of this pin is determined by the last action of the peripheral before the clocks were switched off. the table below summarizes the state of all c165h output pins during idle and power down mode . note: 1) : high if einit was executed before entering idle or power down mode, low otherwise. 2) : for multiplexed buses with 8-bit data bus. c165h output pin(s) idle mode power down mode no external bus external bus enabled no external bus external bus enabled ale low low low low rd , wr high high high high clkout active active high high rstout 1) 1) 1) 1) p0l port latch data floating port latch data floating p0h port latch data a15...a8 2) / float port latch data a15...a8 2) / float port1 port latch data last address 3) / port latch data port latch data last address 3) / port latch data port 4 port latch data port latch data/ last segment port latch data port latch data/ last segment bhe port latch data last value port latch data last value hlda port latch data last value port latch data last value breq port latch data high port latch data high csx port latch data last value 4) port latch data last value 4) other port output pins port latch data / alternate function port latch data / alternate function port latch data / alternate function port latch data / alternate function
c165h power reduction modes data sheet 414 2001-04-19 p r e l i m i n a r y - exc er p t - 3) : for demultiplexed buses. 4) : the cs signal that corresponds to the last address remains active (low), all other enabled cs signals remain inactive (high). by accessing an on-chip x-periperal prior to entering a power save mode all external cs signals can be deactivated. 18.4 extended power management infineon technologies c16x?s well known basic power reduction modes (idle and power down) are enhanced by a number of additional power management features. these features can be combined or selectively used to reduce the controller?s power consumption to the respective application?s possible minimum. according to the sense of platform modularity, the extended power management functions are controlled by different submodules and registers, as follows:: the c165h?s power management functions can be supplemented by the real time clock (rtc) timer with optional periodic wakeup from sleep or idle mode. the periodic wakeup combines the drastically reduced power consumption in power reduction modes (in conjunction with the additional power management features) with a high level of system availability. external signals and events can be scanned (at a lower rate) by periodically activating the cpu and selected peripherals which then return to powersave mode after a short time. this greatly reduces the system?s average power consumption. the rtc is fully controlled by the c165h?s power reduction submodules. the extended power management module controls the sleep mode. the sleep mode is a new power management function which represents and is equal to a power down mode but with exit/wakeup handling as in idle mode. wakeup out of sleep state is possible with all external interrupts (including alternate sources e.g. from asc interface), with nmi and with rtc interrupts. as in idle mode also pec requests are executed in sleep mode, resulting in an interruption and resumption of sleep mode. the watchdog timer is stopped in sleep mode. the contents of internal ram and of cbc?s registers are preserved through the voltage supplied via the vdd pins. as in power down mode, the sleep mode may also be combined with a running real time clock rtc. in sleep mode the oscillators (rtc and selected oscillator optionally), the pll as well as the whole clock system is stopped as in power down state. this implies - contrary to idle mode - , that after wakeup the exit of sleep mode and thus the start of any cpu operation is normally delayed by the ramp-up time of the clock system sub module control register extended power management /sleep mode control syscon1 flexible clock generation management syscon2 flexible peripheral management syscon3
c165h power reduction modes data sheet 415 2001-04-19 p r e l i m i n a r y - exc er pt - (oscillator, pll). only when the pll clock is locked on configured frequency, the system clock is started and the following processing is identical to wakeup from idle mode. for description of idle mode and its possibilities of configuration see chapter 18.1, "idle mode". register in extended power management module : note: syscon1 is a protected register; its security level is automatically set to full write protection after execution of einit instruction. the power reduction modes idle and power down are extended by the infineons c16x devices newly introduced sleep mode. 18.4.1 sleep mode the sleep mode is a new power management function which represents and is equal to a power down mode but with exit/wakeup handling as in idle mode. wakeup from sleep state is possible with all external interrupts (including alternate sources e.g. from ssc interface), with nmi and with rtc interrupts. as in idle mode also pec requests are executed in sleep mode, resulting in an interruption and resumption of sleep mode. the watchdog timer is stopped in sleep mode. the contents of internal ram and registers are preserved through the voltage supplied via the vdd pins. generally, the external bus and the xbus are released during sleep mode if enabled by the hold enable bit hlden in the last program status word psw. if enabled, the signal hlda is active as long as the sleep mode (as well as the idle or power down mode) is active. only when the clock is available again after wakeup, the hold request signal is sampled and the hlda state continued until hold is deactivated. as in power down mode, the sleep mode may also be combined with a running real time clock rtc. in sleep mode the oscillators (rtc and selected oscillator optionally), the pll as well as the whole clock system is stopped as in power down state. this implies, that after wakeup the exit of sleep mode normally is delayed by the ramp-up time of the clock system (oscillator, pll). sleep mode is entered after the standard idle instruction (protected 32 bit instruction) has been executed and the instruction before the idle instruction has been completed. the selection between standard idle mode and sleep mode is controlled with the new register syscon1 (see below). note: sleep mode cannot be entered in slow down mode - the start of sleep mode and wakeup is only possible in the normal clocking mode (pll or direct drive) as defined with the startup configuration on port p0. if sleep mode shall be entered register description syscon1 system configuration control register for sleep management
c165h power reduction modes data sheet 416 2001-04-19 p r e l i m i n a r y - exc er p t - during slow down mode, automatically the standard idle mode is selected as configured with syscon3 register. the sleep mode is controlled by bitfield sleepcon within register syscon1. syscon1 (f1dc h / ee h ) esfr-b reset value: 0000 h note: syscon1 is write protected after the execution of einit unless it is released via the unlock sequence. general description of syscon1 bits: before entering sleep mode with the idle instruction, the continuation of instruction processing after termination of sleep mode must be prepared as known from standard idle mode. for wakeup with interrupt, four general possibilities of continuation can be selected, which are controlled (prepared) as follows:  continuation with first instruction after the idle instruction will be enabled if ? interrupts are globally disabled with the interrupt enable bit in psw, or ? the interrupt is enabled by global (psw) and by individual (interrupt control register) enable bit, but the current cpu priority level (in psw) of idle instruction is higher than the interrupt level.  continuation with first instruction of dedicated interrupt service routine will be selected if the interrupt is enabled by global (in psw) and by individual (interrupt control register) enable bit, and the cpu priority level of idle instruction is lower than the interrupt level, thus the enabled interrupt has highest priority. additionally, pec transfer for this interrupt is not enabled. the continuation with the dedicated service routine is always performed in case of nmi hardware traps, independently of any enable bit or cpu priority level.  execution of one pec transfer and resumption of sleep mode will be selected if the interrupt is enabled by global (in psw) and by individual (interrupt control register) enable bit, and the cpu priority level of idle instruction is lower than the interrupt bit function sleepcon sleep mode configuration ? 0 0 ? : normal idle mode ? 0 1 ? : sleep mode with running rtc ? 1 0 ? : reserved ? 1 1 ? : sleep mode with stopped rtc and stopped osc - - - - - - - - - - 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 --- rw ---- --- - sleepcon -- -rw - - - -
c165h power reduction modes data sheet 417 2001-04-19 p r e l i m i n a r y - exc er pt - level, thus the enabled interrupt has highest priority. additionally, pec transfer for this interrupt is enabled.  continuation with standard idle mode as configured with register syscon3 if the interrupt is not enabled with the individual interrupt enable flag in its interrupt control register. note: in standard idle mode the watchdog timer has to be serviced. for description of syscon3 see description of peripheral management module. as wakeup from idle mode, wakeup from sleep mode is performed with any enabled interrupt request. sleep mode is terminated and the before selected (and above described) continuation of processing is executed, if one of the following interrupts occur:  fast external interrupts (exxint). all fast external interrupts can be selected for wakeup from sleep mode by defining the related trigger transitions (edges) in the exicon register. all transition types are allowed also in sleep mode.  alternate sources for fast external interrupts (exxint) as defined by the exisel register. if selected, transitions on receive lines of serial interface controllers (asc, ssc, iom-2) can be used for wakeup from sleep mode.  rtc timer t14 cyclic interrupt. for waking up from sleep mode via rtc t14 interrupt, the rtc operation during sleep mode must be selected in bitfield sleepcon within register syscon1. additionally, the rtc interrupt must be enabled in the interrupt subnode control register isnc.  rtc interrupt(s) . with new real time clock, additional rtc interrupts can be enabled via the interrupt subnode control register rtcisnc. for wakeup, rtc operation during sleep mode must be selected in syscon1. this function is not supported in c167cs.  non-maskable interrupt nmi . a high-to-low transition on nmi pin always terminates the sleep mode. the nmi input is filtered for spike suppression. (planned: input signals shorter than 10ns are suppressed, detection is guaranteed for minimum 150ns nmi signal). setup lengthening control (start delay) contrary to idle mode, after wakup from sleep mode at first the ramp-up of clock system (oscillator and pll) has to be controlled before any cpu operation can be started. only when the clock system is locked on configured frequency, the following processing is identical to wakeup from idle mode. note: this setup lengthening function is very similar to the start delay after hw-reset because of reset lengthening conditions (see reset section). setup lengthening uses the same lengthening control signals as reset lengthening, but after setup the program start is controlled with the trailing edge of a setup-active signal (contrary to the rst signal in case of reset lengthening) which is provided to the core to delay the execution of first instruction. the system hold state during setup is controlled by start delay of clock distribution.
c165h system control unit (cscu) data sheet 418 2001-04-19 p r e l i m i n a r y - exc er p t - 19 system control unit (cscu) 19.1 introduction the system control unit cscu is used to control system specific tasks such as reset control or power management (see previous chapter "power reduction modes") within an on-chip system build around the infineons cell-based core c166. the power management features of the cscu provide effective means to realize standby conditions for the system with an optimum balance between power reduction, peripheral operation and system functionality. additionally, the cscu controls the modes and operation of real time clock rtc. summary of features and functions the cscu is characterized by the following functions:  central control of system operation ? external interrupt and frequency output control ? protection management for system control registers  general xbus peripherals control ? control of visibility of xpers  power management additional to the standard idle and power down modes ? sleep mode with wakeup from power down state by external interrupts  peripheral management with individual clock and power control of peripherals ? control of power down state of flash modules during idle  flexible clock generation management ? programmable system slow down control with or without pll ? control interface for clock generation unit  identification register block for chip and cscu identification ? device, revision, manufacturer ? cscu identification register 19.2 operational overview 19.2.1 overview of cscu submodules in the following paragraphs a functional overview of the different blocks and submodules of the system control unit is presented. xbus peripheral configuration block in the c165h, xbus peripherals can be separately switched on or off by programming the xpercon register. if switched off, the respective peripheral is not visible, meaning, that its address space and its functional pins are not occupied.
c165h system control unit (cscu) data sheet 419 2001-04-19 p r e l i m i n a r y - exc er pt - note: in parallel to the xper control with xpercon register, the visibility of xper address spaces also is controlled with the busact bits in respective xbcon registers (in the c166 core) note: the xper configuration is additionally controlled by means of flexible peripheral management control (see peripheral management module below) for power reduction. register in xper configuration block: system control block this block has several system management functions. the system control block controls the system register write protection, introduced for the system control registers syscon1-3. note: the new register write protection especially supports modularity of design, and is therefore not compatible with the previously known c16x release function, using the release bitfield in syscon2 for write protection. additional control functions of the system control block: ? control of fast external interrupt inputs ? control of external interrupt source selection ? control of interrupt subnode for pll and realtime clock interrupts ? control of spike suppression for fast external interrupts and nmi in sleep mode ? clock output frequency control the system control block provides the following registers: : register description xpercon xbus peripheral control of xper visibility register description scuslc scu security level command register scusls scu security level status and password register exicon external interrupt control register (see chapter 6.8.1, page 115) exisel external interrupt source selection control register (see chapter 6.8.2, page 115) isnc interrupt subnode control register (see chapter 6.8.3, page 117) focon frequency output control register
c165h system control unit (cscu) data sheet 420 2001-04-19 p r e l i m i n a r y - exc er p t - identification register block all new derivatives of infineons c16x microcontroller family provide a set of min. four identification registers (expandable to eight). these registers offer information on the chip manufacturer, the chip type and its memory properties. identification registers in the id block: : 19.3 xbus peripheral configuration block the xbus peripherals can be separately selected for being visible to the user by means of corresponding selection bits in the xpercon register. if not selected and therefore not enabled (not activated with xpercon bit), the peripheral?s address space including sfr addresses and port pins are not occupied by the peripheral, thus the peripheral is not visible and not available. to make an xbus peripheral visible, its related bit in xpercon register must be set before the xpers are globally enabled with xpen-bit in syscon register (during system initialization before einit instruction). note: after reset, no xbus peripheral is selected in xpercon register. the xpercon register is defined as follows: register description idmanuf manufacturer and department idchip identification of device and revision code idmem identification of on-chip program memory (type, size) idprog identification of programming/erasing voltage of on-chip program memory idmem2 identification of additional eeprom, otp, dram or flash memory xpercon (f024 h / 12 h ) esfrreset value : 0000 h 1514131211109876543210 reserved xper 7 xper 6 xper 5 reserved bit field bits type value description reserved 15..8 rw 0 these bits are reserved and must be set to ?0?. xper7 7rw0 1 this bit is reserved and must be set to ?0?. xper6 6rw0 1 this bit is reserved and must be set to ?0?.
c165h system control unit (cscu) data sheet 421 2001-04-19 p r e l i m i n a r y - exc er pt - note: the cscu provides per xpercon bit one enable signal for xper visibility control. these enable signals are routed to the core to be combined with selectable (per module pins) busact functions of xbcon registers. 19.4 system control block 19.4.1 register write protection the system control unit cscu provides two different protection types of registers:  unprotected registers  protectable registers the unprotected registers allow reading and writing (if not read-only) of register values without any restrictions. however, the write access of the protectable registers (security registers) can be programmed for three different modes of security level, whereas the read access is always unprotected:  write protected mode  low protected mode  unprotected mode in write protected mode the registers can not be accessed by a write command. however in low protected mode the registers can be written with a special command sequence (see desription below). if the registers are set to unprotected mode, all write accesses are possible. some register controlled functions and modes which are critical for the c165h?s operation are locked after the execution of einit, so these vital system functions cannot be changed inadvertently eg. by software errors. however, as these security registers control also the power management they need to be accessed during operation to select the appropriate mode. the switching between the different security levels is controlled by a state machine. via a password and a command sequence the security levels can be changed. after reset always the unprotected mode is automatically selected. the einit command switches the security level automatically to protected mode. the low protected mode is especially important for a standby state of the application. this mode allows fast accesses within two commands to the protected registers without removing the protection completely. xper5 5rw0 1 iom-2 module is not visible iom-2 is selected and visible reserved 4..0 rw 0 these bits are reserved and must be set to zero bit field bits type value description
c165h system control unit (cscu) data sheet 422 2001-04-19 p r e l i m i n a r y - exc er p t - security level switching two registers are provided for switching the security level, the security level command register scuslc and the security level status register scusls . the security level command register scuslc is used to control the state machine for switching the security level. the scuslc register is loaded with the different commands of the command sequence necessary to control a change of the security level. it is also used for the one unlock command, which is necessary in the low protected mode to access one protected register. the commands of the (unlock) command sequence are characterized by certain pattern words (as aaaa h ) or by patterns combined with an 8- bit password. for command definition see the following state diagram (figure below). the new password is defined with command 3 and stored in the according 8-bit field in the scusls register. the scuslc register is defined as follow scuslc (f0c0 h / 60 h ) esfrreset value: 0000 h the command definition is described in figure 134 . the security level status register scusls is a read only register which shows the current password, the actual security level and the state of the switching statemachine. the scusls is defined as followes: scusls (f0c2 h / 61 h ) esfrreset value: 0000 h bit function password current password 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw command 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 r password r r state sl reserved
c165h system control unit (cscu) data sheet 423 2001-04-19 p r e l i m i n a r y - exc er pt - the following registers are defined as protected (security) registers:  syscon1  syscon2  syscon3 the following state diagram, figure 134 , shows the state machine for security level switching and for unlock command execution in low protected mode: sl security level 0 0: unprotected write mode 0 1: low protected mode 1 0: reserved 1 1: write protected mode state actual state 0 0 0: wait for first command (command 0) 0 0 1: wait for command 1 0 1 0: wait for command 2 0 1 1: wait for new security level and for new password (command 3) 1 0 0: security registers are unlocked; access to one register is possible ( only in low protected mode) 1 0 1: reserved 1 1 0: reserved 1 1 1: reserved bit function
c165h system control unit (cscu) data sheet 424 2001-04-19 p r e l i m i n a r y - exc er p t - figure 134 statemachine for security level switching write access in low protected mode the write access in low protected mode is also done via a command sequence. first the specific command 4 (see figure above) with the current password has to be written to register scuslc. after this command all security registers are unlocked until the next write access to any cscu register is done. read access is always possible to all registers of the cscu and will not influence the command sequences. in register scuscs the actual status of the command state machine can always be read. it is recommendet to use an atomic sequence for all command sequences. state 0 state 1 state 2 state 3 reset command0 command1 command2 command3 command2 command1 or any other cscu register write or any other cscu register write access access or any other cscu register write access 1) note : 1) only if the security level command register is accessed, the new security level and the new password is valid. command number command 0 aaaa h 1 5554 h 296 h + inverse (old) password 3 000 b + new level + 000 b + new password 4 8e h + inverse (new) password: unlock security register in low protected mode state 4 any cscu write access command4 and low protected mode register
c165h system control unit (cscu) data sheet 425 2001-04-19 p r e l i m i n a r y - exc er pt - 19.4.2 clock output frequency control a clock output signal with programmable frequency (f out ) can be output via pin fout. this clock signal is generated via a reload counter, so the output frequency can be selected in small steps. an optional toggle latch provides a clock signal with a 50% duty cycle. signal f out always provides complete output periods (see signal waveforms below):  when f out is started (foen-->?1?) focnt is loaded from forv  when f out is stopped (foen-->?0?) focnt is stopped when f out has reached (or is) ?0?. figure 135 clock output signal generation register focon provides control over the output signal generation. focon (ffaa h / d5 h ) sfr-b reset value: 0000 h bit function focnt frequency output counter fotl frequency output toggle latch is toggled upon each underflow of focnt. forv frequency output reload value is copied to focnt upon each underflow of focnt. foss focnt f out forv mux f cpu fotl ctrl. foen fotl - foss foen 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw focnt rw rw rw forv -
c165h system control unit (cscu) data sheet 426 2001-04-19 p r e l i m i n a r y - exc er p t - note: it is not recommended to write to any part of bitfield focnt, especially not while the counter is running. writing to focnt prior to starting the counter is obsolete because it will immediatley be reloaded from forv. writing to focnt during operation may produce uninteded counter values. output frequency calculation the output frequency can be calculated as f out = f cpu / ( (forv+1) * 2 (1-foss) ), so f outmin = f cpu / 128 (forv = 3f h , foss = ?0?), and f outmax = f cpu / 1 (forv = 00 h , foss = ?1?). figure 136 signal waveforms note: the output signal (for foss=?1?) is high for the duration of 1 f cpu cycle for all reload values forv > 0. for forv = 0 the output signal corresponds to f cpu . foss frequency output signal select 0: output of the toggle latch: dc=50%. 1: output of the reload counter: dc depends on forv. foen frequency output enable 0: frequency output generation stops when signal f out is/gets low. 1: focnt is running, f out is gated to pin. 1st reload after 0-1 transition. bit function f cpu f out f out 1) 2) 1) 2) 1) foss= ? 1 ? , output of counter 2) foss= ? 0 ? , output of toggle latch foen--> ? 1 ? foen--> ? 0 ? (forv=0) (forv=5) f out 1) 2) (forv=2) the counter stops here the counter starts here
c165h system control unit (cscu) data sheet 427 2001-04-19 p r e l i m i n a r y - exc er pt - connection to output signal f out in the c165h is an alternate function of pin p3.15/clkout/fout. the priority ranking is: p3.15 < fout < clkout. figure 137 connection to port logic (functional approach) note: for the generation of f out pin fout must be switched to output, ie. dp3.15 =?1?. while f out is disabled the pin is controlled by the port latch (see figure above). the port latch p3.15 must be ?0? in order to maintain the fout inactive level on the pin. clock management module flexible clock management this module especially serves for power management support. flexible clock management includes programmable system slow down with additional control of power down and optional real time clock. the slowdown operation is achieved by dividing the oscillator clock by a programmable factor (1...32) resulting in a low frequency device operation which significantly reduces the overall power consumption. the pll may be completely switched off in this mode. this module also controls the oscillator selection (main or auxiliary) for real time clock and for slow down divider. during power down mode, this block controls the operation of rtc and ports. the clock generation is controlled via register syscon2. f out mux f cpu "1" direction portlatch 0 1 mux 0 1 fout_active clken mux 0 1
c165h system control unit (cscu) data sheet 428 2001-04-19 p r e l i m i n a r y - exc er p t - syscon2 ( f1d0 h / e8 h ) esfr-b reset value: 0000.0000.uu00.0000 b note: syscon2 is a security register. the security level is automatically set to write protectection after execution of einit. note: to be compatibile to infineon?s c167cr / 167cs , the power down control pdcon must be programmed to ?10? (rtc = off, ports = on) during the initialisation phase before the execution of einit instruction. the initial state after reset is so defined that a reset does not interrupt the real time clock. bit function pdcon power down control (during power down mode) x0: rtc = off, ports = on (default after reset). x1: rtc = off, ports = off. in power down mode, the rtc of the c165h is always off. bit 5 of syscon2 is don?t care. rcs rtc clock source (not affected by a reset) 0: rtc is switched to synchronous mode. the input is derived from the cpu clock. 1: rtc is switched to asynchronous mode. the input is derived from the rtc_ref_clk (oscillator clock). scs sdd clock source (not affected by a reset) has to be set to ?0?. clkcon clock state control 00: running on configured basic frequency. 01: running on slow down frequency, pll on. 10: running on slow down frequency, pll off. 11: reserved. do not use this combination. clkrel reload counter value for slowdown divider clklock clock signal status bit 0: main oscillator is unstable or pll is unlocked. 1: main oscillator is stable and pll is locked. rcs scs clk lock 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw rw rw rw r rw clkrel clkcon reserved pdcon
c165h system control unit (cscu) data sheet 429 2001-04-19 p r e l i m i n a r y - exc er pt - 19.5 peripheral management module this module especially serves for power management support, controlling dynamically the operation and thus the power consumption of the different peripherals on pd bus and xbus. in each situation (eg. several system operating modes, standby, etc.) only those peripherals may be kept running which are required for the respective functionality. all others can be switched off. it also allows the operation control of whole groups of peripherals. peripheral?s operation is disabled or enabled by controlling the specific clock input. this function also is supported in idle and/or slow down mode. the real time clock (rtc) may be fed by a separate clock driver, so it can be kept running even in power down mode. while a peripheral is disabled its output pins remain in the state they had at the time of disabling. note: in contrast to the peripheral management of infineon?s 16x family the registers of a disabled module are not accessable. only the clock control register of the platform peripheral is accessable. note, the register access is not compatible to the c167cs. the user gets access to the flexible operation control of peripherals via the syscon3 register. this register is defined as follows: syscon3 (f1d4 h / ea h ) esfr-b reset value:0000 h . bit function perdisx peripheral disable flag 0 - 14 ? 0 ? : module is enabled; the peripheral is supplied with the clock signal ? 1 ? : module is disabled; the clock input of peripheral is disabled grpdis peripheral group disable flag (pd-bus and x-bus peripherals) ? 0 ? : peripheral clock driver for peripheral group is enabled ? 1 ? : peripheral clock driver for peripheral group is disabled plldis pll disable flag (additional power savings / noise reduction feature) ? 0 ? : the pll of the c165h is switched on. this is the default configuration. ? 1 ? : the pll is completely switched off. the free running feature and the oscillator watchdog will not work, since there is no pll clock at all. note: it makes sense to switch off the pll in direct drive clock mode only. 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 - - rw rw - rw rw rw rw rw per dis0 - rw rw rw per dis1 per dis2 per dis3 reserved per dis6 per dis7 per dis8 reserved - grp dis re- serv ed reserved pll dis
c165h system control unit (cscu) data sheet 430 2001-04-19 p r e l i m i n a r y - exc er p t - note : please refer to chapter 9.8, "initialization of the c165h?s x-peripherals", for complete register initialization. note : syscon3 is an security register. the security level is automatically set to write protection after execution of einit 19.6 identification registers 19.6.1 introduction the c165h provides a set of 5 identification registers that offer information on the chip, as manufacturer, chip type and its memory properties. the id registers are read only registers. a device that incorporates id registers shall return d5 h as its bootstrap loader identification byte. a standardized routine may then be downloaded which sends the id registers to the serial interface, so the host gets exact information about its partner. 19.6.2 id register description the id registers are placed in the extended sfr area. idmanuf (f07e h / 3f h ) esfr perdisx module type module function (examples for associated peripheral modules) 0 pd-bus unit rtc real time clock 1 pd-bus unit asc usart 2 pd-bus unit ssc synchronous serial channel 3 pd-bus unit gpt12 general purpose timer block 4..5 reserved - reserved, has to be set to ? 0 ? . 6 x-bus unit iom-2 iom-2 interface 7 reserved - reserved, has to be set to ? 0 ? . 8 reserved - reserved, has to be set to ? 0 ? . 9..14 reserved - reserved, has to be set to ? 0 ? . 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 r r manuf dept
c165h system control unit (cscu) data sheet 431 2001-04-19 p r e l i m i n a r y - exc er pt - idchip (f07c h / 3e h ) esfr idmem (f07a h / 3d h ) esfr bit function manuf manufacturer 0c1 h : infineon technologies jedec normalized manufacturer code dept department 04 h : infineon ? s datacom department bit function revision device revision code 03 h : actual device revision code chipid device identification 05 h : infineons c16x device identification bit function size size of on-chip program memory the size of the implemented program memory in terms of 4 k blocks, i.e.. memory-size = *4 kbyte. 000 h : no program memory on the c165h . type type of on-chip program memory identifies the memory type on this silicon. 0 h : romless 1 h : mask rom 2 h : eprom 3 h :flash 4 h :otp 5 h : eeprom 6 h : dram/sram 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 r r chipid chip revision number 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 r r type ( ? 0 h ? ) size ( ? 000 h ? )
c165h system control unit (cscu) data sheet 432 2001-04-19 p r e l i m i n a r y - exc er p t - idprog (f078 h / 3c h ) esfr idmem2 (f076 h / 3b h ) esfr note: idmem2 describes the second block of (program) memory. this register is dedicated to other infineon devices containing flash, eeprom or dram sections. static ram modules are not described with id registers. since there is no program memory on the c165h, idmem2 is set to ?0000 h ?. bit function progvdd programming v dd voltage the voltage of the standard power supply pins required when programming or erasing (if applicable) the on-chip program memory. formula: v dd = 20* / 256 [v] 00 h : no program memory on the c165h . progvpp programming v pp voltage the voltage of the special programming power supply (if existent) required to program or erase (if applicable) the on-chip program memory. formula: v pp = 20* / 256 [v] 00 h : no program memory on the c165h . 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 r r progvpp ( ? 00 h ? ) progvdd ( ? 00 h ? ) 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 r r type ( ? 0 h ? ) size ( ? 000 h ? )
c165h system programming data sheet 433 2001-04-19 p r e l i m i n a r y - exc er pt - 20 system programming to aid in software development, a number of features has been incorporated into the instruction set of the c165h, including constructs for modularity, loops, and context switching. in many cases commonly used instruction sequences have been simplified while providing greater flexibility. the following programming features help to fully utilize this instruction set. instructions provided as subsets of instructions in many cases, instructions found in other microcontrollers are provided as subsets of more powerful instructions in the c165h. this allows the same functionality to be provided while decreasing the hardware required and decreasing decode complexity. in order to aid assembly programming, these instructions, familiar from other microcontrollers, can be built in macros, thus providing the same names. directly substitutable instructions are instructions known from other microcontrollers that can be replaced by the following instructions of the c165h: modification of system flags is performed using bit set or bit clear instructions (bset, bclr ). all bit and word instructions can access the psw register, so no instructions like clear carry or enable interrupts are required. external memory data access does not require special instructions to load data pointers or explicitly load and store external data. the c165h provides a von-neumann memory architecture and its on-chip hardware automatically detects accesses to internal ram, gprs, and sfrs. multiplication and division multiplication and division of words and double words is provided through multiple cycle instructions implementing a booth algorithm. each instruction implicitly uses the 32-bit register md (mdl = lower 16 bits, mdh = upper 16 bits). the mdriu flag (multiply or divide register in use) in register mdc is set whenever either half of this register is written to or when a multiply/divide instruction is started. it is cleared whenever the mdl substituted instruction c165h instruction function clr rn and rn, #0 h clear register cplb bit bmovn bit, bit complement bit dec rn sub rn, #1 h decrement register inc rn add rn, #1 h increment register swapb rn ror rn, #8 h swap bytes within word
c165h system programming data sheet 434 2001-04-19 p r e l i m i n a r y - exc er p t - register is read. because an interrupt can be acknowledged before the contents of register md are saved, this flag is required to alert interrupt routines, which require the use of the multiply/divide hardware, so they can preserve register md. this register, however, only needs to be saved when an interrupt routine requires use of the md register and a previous task has not saved the current result. this flag is easily tested by the jump-on-bit instructions. multiplication or division is simply performed by specifying the correct (signed or unsigned) version of the multiply or divide instruction. the result is then stored in register md. the overflow flag (v) is set if the result from a multiply or divide instruction is greater than 16 bits. this flag can be used to determine whether both word halfs must be transferred from register md. the high portion of register md (mdh) must be moved into the register file or memory first, in order to ensure that the mdriu flag reflects the correct state. the following instruction sequence performs an unsigned 16 by 16-bit multiplication: save: jnb mdriu, start ;test if md was in use. scxt mdc, #0010h ;save and clear control register, ;leaving mdriu set ;(only required for interrupted ;multiply/divide instructions) bset saved ;indicate the save operation push mdh ;save previous md contents... push mdl ;...on system stack start: mulu r1, r2 ;multiply 1616 unsigned, sets mdriu jmpr cc_nv, copyl ;test for only 16-bit result mov r3, mdh ;move high portion of md copyl: mov r4, mdl ;move low portion of md, clears mdriu restore: jnb saved, done ;test if md registers were saved pop mdl ;restore registers pop mdh pop mdc bclr saved ;multiplication is completed, ;program continues done: ... the above save sequence and the restore sequence after copyl are only required if the current routine could have interrupted a previous routine which contained a mul or div instruction. register mdc is also saved because it is possible that a previous routine's multiply or divide instruction was interrupted while in progress. in this case the information about how to restart the instruction is contained in this register. register mdc must be cleared to be correctly initialized for a subsequent multiplication or
c165h system programming data sheet 435 2001-04-19 p r e l i m i n a r y - exc er pt - division. the old mdc contents must be popped from the stack before the reti instruction is executed. for a division the user must first move the dividend into the md register. if a 16/16-bit division is specified, only the low portion of register md must be loaded. the result is also stored into register md. the low portion (mdl) contains the integer result of the division, while the high portion (mdh) contains the remainder. the following instruction sequence performs a 32 by 16-bit division: mov mdh, r1 ;move dividend to md register. sets mdriu mov mdl, r2 ;move low portion to md div r3 ;divide 32/16 signed, r3 holds divisor jmpr cc_v, error ;test for divide overflow mov r3, mdh ;move remainder to r3 mov r4, mdl ;move integer result to r4. clears mdriu whenever a multiply or divide instruction is interrupted while in progress, the address of the interrupted instruction is pushed onto the stack and the mulip flag in the psw of the interrupting routine is set. when the interrupt routine is exited with the reti instruction, this bit is implicitly tested before the old psw is popped from the stack. if mulip=?1? the multiply/divide instruction is re-read from the location popped from the stack (return address) and will be completed after the reti instruction has been executed. note: the mulip flag is part of the context of the interrupted task . when the interrupting routine does not return to the interrupted task (eg. scheduler switches to another task) the mulip flag must be set or cleared according to the context of the task that is switched to. bcd calculations no direct support for bcd calculations is provided in the c165h. bcd calculations are performed by converting bcd data to binary data, performing the desired calculations using standard data types, and converting the result back to bcd data. due to the enhanced performance of division instructions binary data is quickly converted to bcd data through division by 10 d . conversion from bcd data to binary data is enhanced by multiple bit shift instructions. this provides similar performance compared to instructions directly supporting bcd data types, while no additional hardware is required. 20.1 stack operations the c165h supports two types of stacks. the system stack is used implicitly by the controller and is located in the internal ram. the user stack provides stack access to the user in either the internal or external memory. both stack types grow from high memory addresses to low memory addresses.
c165h system programming data sheet 436 2001-04-19 p r e l i m i n a r y - exc er p t - internal system stack a system stack is provided to store return vectors, segment pointers, and processor status for procedures and interrupt routines. a system register, sp, points to the top of the stack. this pointer is decremented when data is pushed onto the stack, and incremented when data is popped. the internal system stack can also be used to temporarily store data or pass it between subroutines or tasks. instructions are provided to push or pop registers on/from the system stack. however, in most cases the register banking scheme provides the best performance for passing data between multiple tasks. note: the system stack allows the storage of words only. bytes must either be converted to words or the respective other byte must be disregarded. register sp can only be loaded with even byte addresses (the lsb of sp is always '0'). detection of stack overflow/underflow is supported by two registers, stkov (stack overflow pointer) and stkun (stack underflow pointer). specific system traps (stack overflow trap, stack underflow trap) will be entered whenever the sp reaches either boundary specified in these registers. the contents of the stack pointer are compared to the contents of the overflow register, whenever the sp is decremented either by a call, push or sub instruction. an overflow trap will be entered, when the sp value is less than the value in the stack overflow register. the contents of the stack pointer are compared to the contents of the underflow register, whenever the sp is incremented either by a ret, pop or add instruction. an underflow trap will be entered, when the sp value is greater than the value in the stack underflow register. note: when a value is moved into the stack pointer, no check against the overflow/ underflow registers is performed. in many cases the user will place a software reset instruction (srst) into the stack underflow and overflow trap service routines. this is an easy approach, which does not require special programming. however, this approach assumes that the defined internal stack is sufficient for the current software and that exceeding its upper or lower boundary represents a fatal error. it is also possible to use the stack underflow and stack overflow traps to cache portions of a larger external stack. only the portion of the system stack currently being used is placed into the internal memory, thus allowing a greater portion of the internal ram to be used for program, data or register banking. this approach assumes no error but requires a set of control routines (see below).
c165h system programming data sheet 437 2001-04-19 p r e l i m i n a r y - exc er pt - circular (virtual) stack this basic technique allows pushing until the overflow boundary of the internal stack is reached. at this point a portion of the stacked data must be saved into external memory to create space for further stack pushes. this is called ?stack flushing?. when executing a number of return or pop instructions, the upper boundary (since the stack empties upward to higher memory locations) is reached. the entries that have been previously saved in external memory must now be restored. this is called ?stack filling?. because procedure call instructions do not continue to nest infinitely and call and return instructions alternate, flushing and filling normally occurs very infrequently. if this is not true for a given program environment, this technique should not be used because of the overhead of flushing and filling. the basic mechanism is the transformation of the addresses of a virtual stack area, controlled via registers sp, stkov and stkun, to a defined physical stack area within the internal ram via hardware. this virtual stack area covers all possible locations that sp can point to, ie. 00?f000 h through 00?fffe h . stkov and stkun accept the same 4 kbyte address range. the size of the physical stack area within the internal ram that effectively is used for standard stack operations is defined via bitfield stksz in register syscon (see below). the virtual stack addresses are transformed to physical stack addresses by concatenating the significant bits of the stack pointer register sp (see table) with the complementary most significant bits of the upper limit of the physical stack area (00?fbfe h ). this transformation is done via hardware (see figure below). stack size (words) internal ram addresses (words) of physical stack significant bits of stack pointer sp 0 0 0 b 256 00?fbfe h ...00?fa00 h (default after reset) sp.8...sp.0 0 0 1 b 128 00?fbfe h ...00?fb00 h sp.7...sp.0 0 1 0 b 64 00?fbfe h ...00?fb80 h sp.6...sp.0 0 1 1 b 32 00?fbfe h ...00?fbc0 h sp.5...sp.0 1 0 0 b 512 00?fbfe h ...00?f800 h (not for 1 kbyte iram) sp.9...sp.0 1 0 1 b --- reserved. do not use this combination. --- 1 1 0 b --- reserved. do not use this combination. --- 1 1 1 b 1024 00?fdfe h ...00?fx00 h (note: no circular stack) 00?fx00 h represents the lower iram limit, ie. 1 kb: 00?fa00 h , 2 kb: 00?f600 h , 3 kb: 00?f200 h sp.11...sp.0
c165h system programming data sheet 438 2001-04-19 p r e l i m i n a r y - exc er p t - the reset values (stkov=fa00 h , stkun=fc00 h , sp=fc00 h , stksz=000 b ) map the virtual stack area directly to the physical stack area and allow using the internal system stack without any changes, provided that the 256 word area is not exceeded. figure 138 physical stack address generation the following example demonstrates the circular stack mechanism which is also an effect of this virtual stack mapping: first, register r1 is pushed onto the lowest physical stack location according to the selected maximum stack size. with the following instruction, register r2 will be pushed onto the highest physical stack location although the sp is decremented by 2 as for the previous push operation. mov sp, #0f802h ;set sp before last entry... ;...of physical stack of 256 words ... ;(sp)=f802h: physical stack addr.=fa02h push r1 ;(sp)=f800h: physical stack addr.=fa00h push r2 ;(sp)=f7feh: physical stack addr.=fbfeh the effect of the address transformation is that the physical stack addresses wrap around from the end of the defined area to its beginning. when flushing and filling the internal stack, this circular stack mechanism only requires to move that portion of stack 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 0 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 fbfe h fb80 h fb80 h fbfe h fb7e h fbfe h fbfe h 64 words 256 words f800 h 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 fa00 h 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 fbfe h f7fe h fbfe h 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 phys.a. phys.a. stack size after push after push
c165h system programming data sheet 439 2001-04-19 p r e l i m i n a r y - exc er pt - data which is really to be re-used (ie. the upper part of the defined stack area) instead of the whole stack area. stack data that remain in the lower part of the internal stack need not be moved by the distance of the space being flushed or filled, as the stack pointer automatically wraps around to the beginning of the freed part of the stack area. note: this circular stack technique is applicable for stack sizes of 32 to 512 words (stksz = ?000 b ? to ?100 b ?), it does not work with option stksz = ?111 b ?, which uses the complete internal ram for system stack. in the latter case the address transformation mechanism is deactivated. when a boundary is reached, the stack underflow or overflow trap is entered, where the user moves a predetermined portion of the internal stack to or from the external stack. the amount of data transferred is determined by the average stack space required by routines and the frequency of calls, traps, interrupts and returns. in most cases this will be approximately one quarter to one tenth the size of the internal stack. once the transfer is complete, the boundary pointers are updated to reflect the newly allocated space on the internal stack. thus, the user is free to write code without concern for the internal stack limits. only the execution time required by the trap routines affects user programs. the following procedure initializes the controller for usage of the circular stack mechanism:  specify the size of the physical system stack area within the internal ram (bitfield stksz in register syscon).  define two pointers, which specify the upper and lower boundary of the external stack. these values are then tested in the stack underflow and overflow trap routines when moving data.  set the stack overflow pointer (stkov) to the limit of the defined internal stack area plus six words (for the reserved space to store two interrupt entries). the internal stack will now fill until the overflow pointer is reached. after entry into the overflow trap procedure, the top of the stack will be copied to the external memory. the internal pointers will then be modified to reflect the newly allocated space. after exiting from the trap procedure, the internal stack will wrap around to the top of the internal stack, and continue to grow until the new value of the stack overflow pointer is reached. when the underflow pointer is reached while the stack is meptied the bottom of stack is reloaded from the external memory and the internal pointers are adjusted accordingly. linear stack the c165h also offers a linear stack option (stksz = ?111 b ?), where the system stack may use the complete internal ram area. this provides a large system stack without requiring procedures to handle data transfers for a circular stack. however, this method also leaves less ram space for variables or code. the ram area that may effectively be consumed by the system stack is defined via the stkun and stkov pointers. the underflow and overflow traps in this case serve for fatal error detection only.
c165h system programming data sheet 440 2001-04-19 p r e l i m i n a r y - exc er p t - for the linear stack option all modifiable bits of register sp are used to access the physical stack. although the stack pointer may cover addresses from 00?f000 h up to 00?fffe h the (physical) system stack must be located within the internal ram and therefore may only use the address range 00?f600 h to 00?fdfe h . it is the user?s responsibility to restrict the system stack to the internal ram range. note: avoid stack accesses below the iram area (esfr space and reserved area) and within address range 00?fe00 h and 00?fffe h (sfr space). otherwise unpredictable results will occur. user stacks user stacks provide the ability to create task specific data stacks and to off-load data from the system stack. the user may push both bytes and words onto a user stack, but is responsible for using the appropriate instructions when popping data from the specific user stack. no hardware detection of overflow or underflow of a user stack is provided. the following addressing modes allow implementation of user stacks: [? rw], rb or [? rw], rw : pre-decrement indirect addressing. used to push one byte or word onto a user stack. this mode is only available for mov instructions and can specify any gpr as the user stack pointer. rb, [rw+] or rw, [rw+] : post-increment index register indirect addressing. used to pop one byte or word from a user stack. this mode is available to most instructions, but only gprs r0-r3 can be specified as the user stack pointer. rb, [rw+] or rw, [rw+] : post-increment indirect addressing. used to pop one byte or word from a user stack. this mode is only available for mov instructions and can specify any gpr as the user stack pointer. 20.2 register banking register banking provides the user with an extremely fast method to switch user context. a single machine cycle instruction saves the old bank and enters a new register bank. each register bank may assign up to 16 registers. each register bank should be allocated during coding based on the needs of each task. once the internal memory has been partitioned into a register bank space, internal stack space and a global internal memory area, each bank pointer is then assigned. thus, upon entry into a new task, the appropriate bank pointer is used as the operand for the scxt (switch context) instruction. upon exit from a task a simple pop instruction to the context pointer (cp) restores the previous task's register bank.
c165h system programming data sheet 441 2001-04-19 p r e l i m i n a r y - exc er pt - 20.3 procedure call entry and exit to support modular programming a procedure mechanism is provided to allow coding of frequently used portions of code into subroutines. the call and ret instructions store and restore the value of the instruction pointer (ip) on the system stack before and after a subroutine is executed. procedures may be called conditionally with instructions calla or calli, or be called unconditionally using instructions callr or calls. note: any data pushed onto the system stack during execution of the subroutine must be popped before the ret instruction is executed. passing parameters on the system stack parameters may be passed via the system stack through push instructions before the subroutine is called, and pop instructions during execution of the subroutine. base plus offset indirect addressing also permits access to parameters without popping these parameters from the stack during execution of the subroutine. indirect addressing provides a mechanism of accessing data referenced by data pointers, which are passed to the subroutine. in addition, two instructions have been implemented to allow one parameter to be passed on the system stack without additional software overhead. the pcall (push and call) instruction first pushes the 'reg' operand and the ip contents onto the system stack and then passes control to the subroutine specified by the 'caddr' operand. when exiting from the subroutine, the retp (return and pop) instruction first pops the ip and then the 'reg' operand from the system stack and returns to the calling program. cross segment subroutine calls calls to subroutines in different segments require the use of the calls (call inter- segment subroutine) instruction. this instruction preserves both the csp (code segment pointer) and ip on the system stack. upon return from the subroutine, a rets (return from inter-segment subroutine) instruction must be used to restore both the csp and ip. this ensures that the next instruction after the calls instruction is fetched from the correct segment. note: it is possible to use calls within the same segment, but still two words of the stack are used to store both the ip and csp. providing local registers for subroutines for subroutines which require local storage, the following methods are provided:
c165h system programming data sheet 442 2001-04-19 p r e l i m i n a r y - exc er p t - alternate bank of registers: upon entry into a subroutine, it is possible to specify a new set of local registers by executing the scxt (switch context) instruction. this mechanism does not provide a method to recursively call a subroutine. saving and restoring of registers: to provide local registers, the contents of the registers which are required for use by the subroutine can be pushed onto the stack and the previous values be popped before returning to the calling routine. this is the most common technique used today and it does provide a mechanism to support recursive procedures. this method, however, requires two machine cycles per register stored on the system stack (one cycle to push the register, and one to pop the register). use of the system stack for local registers: it is possible to use the sp and cp to set up local subroutine register frames. this enables subroutines to dynamically allocate local variables as needed within two machine cycles. a local frame is allocated by simply subtracting the number of required local registers from the sp, and then moving the value of the new sp to the cp. this operation is supported through the scxt (switch context) instruction with the addressing mode 'reg, mem'. using this instruction saves the old contents of the cp on the system stack and moves the value of the sp into cp (see example below). each local register is then accessed as if it was a normal register. upon exit from the subroutine, first the old cp must be restored by popping it from the stack and then the number of used local registers must be added to the sp to restore the allocated local space back to the system stack. note: the system stack is growing downwards, while the register bank is growing upwards. figure 139 local registers old stack area newly allocated register bank r4 r3 r2 r1 r0 old cp contents old sp new sp new cp new stack area
c165h system programming data sheet 443 2001-04-19 p r e l i m i n a r y - exc er pt - the software to provide the local register bank for the example above is very compact: after entering the subroutine: sub sp, #10d ;free 5 words in the current system stack scxt cp, sp ;set the new register bank pointer before exiting the subroutine: pop cp ;restore the old register bank add sp, #10d ;release the 5 words... ;...of the current system stack 20.4 table searching a number of features have been included to decrease the execution time required to search tables. first, branch delays are eliminated by the branch target cache after the first iteration of the loop. second, in non-sequentially searched tables, the enhanced performance of the alu allows more complicated hash algorithms to be processed to obtain better table distribution. for sequentially searched tables, the auto-increment indirect addressing mode and the e (end of table) flag stored in the psw decrease the number of overhead instructions executed in the loop. the two examples below illustrate searching ordered tables and non-ordered tables, respectively: mov r0, #base ;move table base into r0 loop: cmp r1, [r0+] ;compare target to table entry jmpr cc_sgt, loop ;test whether target has not been found note: the last entry in the table must be greater than the largest possible target. mov r0, #base ;move table base into r0 loop: cmp r1, [r0+] ;compare target to table entry jmpr cc_net, loop ;test whether target is not found and.. ;..the end of table has not been reached. note: the last entry in the table must be equal to the lowest signed integer (8000 h ).
c165h system programming data sheet 444 2001-04-19 p r e l i m i n a r y - exc er p t - 20.5 peripheral control and interface all communication between peripherals and the cpu is performed either by pec transfers to and from internal memory, or by explicitly addressing the sfrs associated with the specific peripherals. after resetting the c165h all peripherals (except the watchdog timer) are disabled and initialized to default values. a desired configuration of a specific peripheral is programmed using mov instructions of either constants or memory values to specific sfrs. specific control flags may also be altered via bit instructions. once in operation, the peripheral operates autonomously until an end condition is reached at which time it requests a pec transfer or requests cpu servicing through an interrupt routine. information may also be polled from peripherals through read accesses to sfrs or bit operations including branch tests on specific control bits in sfrs. to ensure proper allocation of peripherals among multiple tasks, a portion of the internal memory has been made bit addressable to allow user semaphores. instructions have also been provided to lock out tasks via software by setting or clearing user specific bits and conditionally branching based on these specific bits. it is recommended that bit fields in control sfrs are updated using the bfldh and bfldl instructions or a mov instruction to avoid undesired intermediate modes of operation which can occur, when bclr/bset or and/or instruction sequences are used. 20.6 floating point support all floating point operations are performed using software. standard multiple precision instructions are used to perform calculations on data types that exceed the size of the alu. multiple bit rotate and logic instructions allow easy masking and extracting of portions of floating point numbers. to decrease the time required to perform floating point operations, two hardware features have been implemented in the cpu core. first, the prior instruction aids in normalizing floating point numbers by indicating the position of the first set bit in a gpr. this result can the be used to rotate the floating point result accordingly. the second feature aids in properly rounding the result of normalized floating point numbers through the overflow (v) flag in the psw. this flag is set when a one is shifted out of the carry bit during shift right operations. the overflow flag and the carry flag are then used to round the floating point result based on the desired rounding algorithm. 20.7 trap/interrupt entry and exit interrupt routines are entered when a requesting interrupt has a priority higher than the current cpu priority level. traps are entered regardless of the current cpu priority. when either a trap or interrupt routine is entered, the state of the machine is preserved on the system stack and a branch to the appropriate trap/interrupt vector is made.
c165h system programming data sheet 445 2001-04-19 p r e l i m i n a r y - exc er pt - all trap and interrupt routines require the use of the reti (return from interrupt) instruction to exit from the called routine. this instruction restores the system state from the system stack and then branches back to the location where the trap or interrupt occurred. 20.8 unseparable instruction sequences the instructions of the c165h are very efficient (most instructions execute in one machine cycle) and even the multiplication and division are interruptable in order to minimize the response latency to interrupt requests (internal and external). in many microcontroller applications this is vital. some special occasions, however, require certain code sequences (eg. semaphore handling) to be uninterruptable to function properly. this can be provided by inhibiting interrupts during the respective code sequence by disabling and enabling them before and after the sequence. the necessary overhead may be reduced by means of the atomic instruction which allows locking 1...4 instructions to an unseparable code sequence, during which the interrupt system (standard interrupts and pec requests) and class a traps (nmi , stack overflow/underflow) are disabled. a class b trap (illegal opcode, illegal bus access, etc.), however, will interrupt the atomic sequence, since it indicates a severe hardware problem. the interrupt inhibit caused by an atomic instruction gets active immediately, ie. no other instruction will enter the pipeline except the one that follows the atomic instruction, and no interrupt request will be serviced in between. all instructions requiring multiple cycles or hold states are regarded as one instruction in this sense (eg. mul is one instruction). any instruction type can be used within an unseparable code sequence. atomic #3 ;the next 3 instr. are locked (no nop requ.) mov r0, #1234h ;instr. 1 (no other instr. enters pipeline!) mov r1, #5678h ;instr. 2 mul r0, r1 ;instr. 3: mul regarded as one instruction mov r2, mdl ;this instruction is out of the scope... ;...of the atomic instruction sequence 20.9 overriding the dpp addressing mechanism the standard mechanism to access data locations uses one of the four data page pointers (dppx), which selects a 16 kbyte data page, and a 14-bit offset within this data page. the four dpps allow immediate access to up to 64 kbyte of data. in applications with big data arrays, especially in hll applications using large memory models, this may require frequent reloading of the dpps, even for single accesses.
c165h system programming data sheet 446 2001-04-19 p r e l i m i n a r y - exc er p t - the extp (extend page) instruction allows switching to an arbitrary data page for 1...4 instructions without having to change the current dpps. extp r15, #1 ;the override page number is stored in r15 mov r0, [r14] ;the (14-bit) page offset is stored in r14 mov r1, [r13] ;this instruction uses the std. dpp scheme! the exts (extend segment) instruction allows switching to a 64 kbyte segment oriented data access scheme for 1...4 instructions without having to change the current dpps. in this case all 16 bits of the operand address are used as segment offset, with the segment taken from the exts instruction. this greatly simplifies address calculation with continuous data like huge arrays in ?c?. exts #15, #1 ;the override seg. is 15 (0f?0000h..0f?ffffh) mov r0, [r14] ;the (16-bit) segment offset is stored in r14 mov r1, [r13] ;this instruction uses the std. dpp scheme! note: instructions extp and exts inhibit interrupts the same way as atomic. short addressing in the extended sfr (esfr) space the short addressing modes of the c165h (reg or bitoff) implicitly access the sfr space. the additional esfr space would have to be accessed via long addressing modes (mem or [rw]). the extr (extend register) instruction redirects accesses in short addressing modes to the esfr space for 1...4 instructions, so the additional registers can be accessed this way, too. the extpr and extsr instructions combine the dpp override mechanism with the redirection to the esfr space using a single instruction. note: instructions extr, extpr and extsr inhibit interrupts the same way as atomic. the switching to the esfr area and data page overriding is checked by the development tools or handled automatically. nested locked sequences each of the described extension instruction and the atomic instruction starts an internal ?extension counter? counting the effected instructions. when another extension or atomic instruction is contained in the current locked sequence this counter is restarted with the value of the new instruction. this allows the construction of locked sequences longer than 4 instructions. note:  interrupt latencies may be increased when using locked code sequences.  pec requests are not serviced during idle mode, if the idle instruction is part of a locked sequence.
c165h system programming data sheet 447 2001-04-19 p r e l i m i n a r y - exc er pt - code memory configuration during reset the control input pin ea (external access) enables the user to define the address area from which the first instructions after reset are fetched. when ea is low (?0?) during reset, the internal code memory is disabled and the first instructions are fetched from external memory. when ea is high (?1?) during reset, the internal code memory is globally enabled and the first instructions are fetched from the internal memory. enabling and disabling the internal code memory after reset if the internal code memory does not contain an appropriate startup code, the system may be booted from external memory, while the internal memory is enabled afterwards to provide access to library routines, tables, etc. if the internal code memory only contains the startup code and/or test software, the system may be booted from internal memory, which may then be disabled, after the software has switched to executing from (eg.) external memory, in order to free the address space occupied by the internal code memory, which is now unnecessary. 20.10 pits, traps and mines although handling the internal code memory provides powerful means to enhance the overall performance and flexibility of a system, extreme care must be taken in order to avoid a system crash. instruction memory is the most crucial resource for the c165h and it must be made sure that it never runs out of it. the following precautions help to take advantage of the methods mentioned above without jeopardizing system security. general rules when mapping the code memory no instruction or data accesses should be made to the internal memory, otherwise unpredictable results may occur. to avoid these problems, the instructions that configure the internal code memory should be executed from external memory or from the on-chip ram. whenever the internal code memory is disabled, enabled or remapped the dpps must be explicitly (re)loaded to enable correct data accesses to the internal and/or external memory.
c165h register set data sheet 448 2001-04-19 p r e l i m i n a r y - exc er p t - 21 register set this section summarizes all registers, which are implemented in the c165h and explains the description format which is used in the chapters describing the function and layout of the sfrs. for easy reference the registers are ordered according to two different keys (except for gprs):  ordered by address, to check which register a given address references,  ordered by register name, to find the location of a specific register. 21.1 register description format in the respective chapters the function and the layout of the sfrs is described in a specific format which provides a number of details about the described special function register. the example below shows how to interpret these details. a word register looks like this: reg_name ( a16 h / a8 h ) e /sfr reset value: * * * * h a byte register looks like this: reg_name ( a16 h / a8 h ) e /sfr reset value: - - * * h elements: reg_name name of this register a16 / a8 long 16-bit address / short 8-bit address sfr /esfr / xreg register space (sfr, esfr or external/xbus register) (* *) * * register contents after reset 0/1 : defined value, ? x ? : undefined, ? u ? : unchanged (undefined ( ? x ? ) after power up) bits that are set/cleared by hardware are marked with a shaded access box bit function bit(field)name explanation of bit(field)name description of the functions controlled by this bit(field) . 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw - w rw r rw rw - - - - res. res. res. res. res. write only read only bitfield bitfield hw bit std bit hw bit 5 4 3 2 1 0 11 10 9 8 7 6 15 14 13 12 rw rw - - - - rw rw - - - - bitfield bitfield std bit hw bit hwbit
c165h register set data sheet 449 2001-04-19 p r e l i m i n a r y - exc er pt - 21.2 cpu general purpose registers (gprs) the gprs form the register bank that the cpu works with. this register bank may be located anywhere within the internal ram via the context pointer (cp). due to the addressing mechanism, gpr banks can only reside within the internal ram. all gprs are bit-addressable. the first 8 gprs (r7...r0) may also be accessed bytewise. other than with sfrs, writing to a gpr byte does not affect the other byte of the respective gpr. the respective halves of the byte-accessible registers receive special names: name physical address 8-bit address description reset value r0 (cp) + 0 f0 h cpu general purpose (word) register r0 uuuu h r1 (cp) + 2 f1 h cpu general purpose (word) register r1 uuuu h r2 (cp) + 4 f2 h cpu general purpose (word) register r2 uuuu h r3 (cp) + 6 f3 h cpu general purpose (word) register r3 uuuu h r4 (cp) + 8 f4 h cpu general purpose (word) register r4 uuuu h r5 (cp) + 10 f5 h cpu general purpose (word) register r5 uuuu h r6 (cp) + 12 f6 h cpu general purpose (word) register r6 uuuu h r7 (cp) + 14 f7 h cpu general purpose (word) register r7 uuuu h r8 (cp) + 16 f8 h cpu general purpose (word) register r8 uuuu h r9 (cp) + 18 f9 h cpu general purpose (word) register r9 uuuu h r10 (cp) + 20 fa h cpu general purpose (word) register r10 uuuu h r11 (cp) + 22 fb h cpu general purpose (word) register r11 uuuu h r12 (cp) + 24 fc h cpu general purpose (word) register r12 uuuu h r13 (cp) + 26 fd h cpu general purpose (word) register r13 uuuu h r14 (cp) + 28 fe h cpu general purpose (word) register r14 uuuu h r15 (cp) + 30 ff h cpu general purpose (word) register r15 uuuu h name physical address 8-bit address description reset value rl0 (cp) + 0 f0 h cpu general purpose (byte) register rl0 uu h rh0 (cp) + 1 f1 h cpu general purpose (byte) register rh0 uu h rl1 (cp) + 2 f2 h cpu general purpose (byte) register rl1 uu h
c165h register set data sheet 450 2001-04-19 p r e l i m i n a r y - exc er p t - 21.3 special function registers ordered by address the following table lists all sfrs which are implemented in the c165h ordered by physical address. bit- addressable sfrs are marked with the letter ? b ? in column ? type ? . sfrs within the extended sfr-space (esfrs) are marked with the letter ? e ? in column ? type ? . table 75 registers ordered by address rh1 (cp) + 3 f3 h cpu general purpose (byte) register rh1 uu h rl2 (cp) + 4 f4 h cpu general purpose (byte) register rl2 uu h rh2 (cp) + 5 f5 h cpu general purpose (byte) register rh2 uu h rl3 (cp) + 6 f6 h cpu general purpose (byte) register rl3 uu h rh3 (cp) + 7 f7 h cpu general purpose (byte) register rh3 uu h rl4 (cp) + 8 f8 h cpu general purpose (byte) register rl4 uu h rh4 (cp) + 9 f9 h cpu general purpose (byte) register rh4 uu h rl5 (cp) + 10 fa h cpu general purpose (byte) register rl5 uu h rh5 (cp) + 11 fb h cpu general purpose (byte) register rh5 uu h rl6 (cp) + 12 fc h cpu general purpose (byte) register rl6 uu h rh6 (cp) + 13 fd h cpu general purpose (byte) register rh6 uu h rl7 (cp) + 14 fe h cpu general purpose (byte) register rl7 uu h rh7 (cp) + 14 ff h cpu general purpose (byte) register rh7 uu h physical addr register name type 8-bit addr description reset value r0 sfr-b f0 h general purpose register 0 uuuu h r0 esfr-b f0 h general purpose register 0 uuuu h r1 sfr-b f1 h general purpose register 1 uuuu h r1 esfr-b f1 h general purpose register 1 uuuu h r10 esfr-b fa h general purpose register 10 uuuu h r10 sfr-b fa h general purpose register 10 uuuu h r11 sfr-b fb h general purpose register 11 uuuu h r11 esfr-b fb h general purpose register 11 uuuu h r12 sfr-b fc h general purpose register 12 uuuu h r12 esfr-b fc h general purpose register 12 uuuu h r13 sfr-b fd h general purpose register 13 uuuu h r13 esfr-b fd h general purpose register 13 uuuu h r14 sfr-b fe h general purpose register 14 uuuu h name physical address 8-bit address description reset value
c165h register set data sheet 451 2001-04-19 p r e l i m i n a r y - exc er pt - r14 esfr-b fe h general purpose register 14 uuuu h r15 esfr-b ff h general purpose register 15 uuuu h r15 sfr-b ff h general purpose register 15 uuuu h r2 sfr-b f2 h general purpose register 2 uuuu h r2 esfr-b f2 h general purpose register 2 uuuu h r3 sfr-b f3 h general purpose register 3 uuuu h r3 esfr-b f3 h general purpose register 3 uuuu h r4 esfr-b f4 h general purpose register 4 uuuu h r4 sfr-b f4 h general purpose register 4 uuuu h r5 esfr-b f5 h general purpose register 5 uuuu h r5 sfr-b f5 h general purpose register 5 uuuu h r6 esfr-b f6 h general purpose register 6 uuuu h r6 sfr-b f6 h general purpose register 6 uuuu h r7 esfr-b f7 h general purpose register 7 uuuu h r7 sfr-b f7 h general purpose register 7 uuuu h r8 sfr-b f8 h general purpose register 8 uuuu h r8 esfr-b f8 h general purpose register 8 uuuu h r9 sfr-b f9 h general purpose register 9 uuuu h r9 esfr-b f9 h general purpose register 9 uuuu h f014 h xadrs1 esfr 0a h xbus address select register 1 f016 h xadrs2 esfr 0b h xbus address select register 2 f018 h xadrs3 esfr 0c h xbus address select register 3 f01a h xadrs4 esfr 0d h xbus address select register 4 f01c h xadrs5 esfr 0e h xbus address select register 5 f01e h xadrs6 esfr 0f h xbus address select register 6 f024 h xpercon esfr 12 h xbus peripheral control register 0401 h f076 h idmem2 esfr 3b h identifier 0000 h f078 h idprog esfr 3c h identifier 0000 h f07a h idmem esfr 3d h identifier 0000 h f07c h idchip esfr 3e h identifier 0503 h f07e h idmanuf esfr 3f h identifier 1824 h f0b0 h ssctb esfr 58 h ssc transmit buffer (wo) 0000 h f0b2 h sscrb esfr 59 h ssc receive buffer (ro) xxxx h f0b4 h sscbr esfr 5a h ssc baudrate register 0000 h f0b6 h sscclc esfr 5b h ssc clock control register 0000 h physical addr register name type 8-bit addr description reset value
c165h register set data sheet 452 2001-04-19 p r e l i m i n a r y - exc er p t - f0c0 h scuslc esfr 60 h security level control register 0000 h f0c2 h scusls esfr 61 h security level status register 0000 h f0c8 h rtcclc esfr 64 h rtc clock control register 0000 h f0cc h rtcrell esfr 66 h rtc timer reload register low 0000 h f0ce h rtcrelh esfr 67 h rtc timer reload register high 0000 h f0d0 h t14rel esfr 68 h timer 14 reload register n h f0d2 h t14 esfr 69 h timer 14 register n h f0d4 h rtcl esfr 6a h rtc timer register low n h f0d6 h rtch esfr 6b h rtc timer register high n h f0d8 h dtidr esfr 6c h task id register 1) 0000 h f100 h dp0l esfr-b 80 h p0l direction control register 00 h f102 h dp0h esfr-b 81 h p0h direction control register 00 h f104 h dp1l esfr-b 82 h p1l direction control register 00 h f106 h dp1h esfr-b 83 h p1h direction control register 00 h f108 h rp0h esfr-b 84 h system startup configuration register (ro) xx h f114 h xbcon1 esfr-b 8a h xbus control register 1: iom-2 module 0000 h f116 h xbcon2 esfr-b 8b h xbus control register 2: reserved 0000 h f118 h xbcon3 esfr-b 8c h xbus control register 3: reserved 0000 h f11a h xbcon4 esfr-b 8d h xbus control register 4: reserved 0000 h f11c h xbcon5 esfr-b 8e h xbus control register 5: reserved 0000 h f11e h xbcon6 esfr-b 8f h xbus control register 6: reserved 0000 h f160 h utd3ic esfr-b b0 h udc tx done3 interrupt control register 0000 h f162 h utd4ic esfr-b b1 h udc tx done4 interrupt control register 0000 h f164 h utd5ic esfr-b b2 h udc tx done5 interrupt control register 0000 h f166 h utd6ic esfr-b b3 h udc tx done6 interrupt control register 0000 h f168 h utd7ic esfr-b b4 h udc tx done7 interrupt control register 0000 h f16a h urxric esfr-b b5 h udc rxrr interrupt control register 0000 h f16c h utxric esfr-b b6 h udc txwr interrupt control register 0000 h f16e h ucfgvic esfr-b b7 h udc config val interrupt control register 0000 h f170 h usofic esfr-b b8 h udc start of frame interrupt control register 0000 h f172 h ussoic esfr-b b9 h udc suspend off interrupt control register 0000 h f174 h ussic esfr-b ba h udc suspend interrupt control register 0000 h f176 h ulcdic esfr-b bb h udc load config done interrupt control register 0000 h f178 h usetic esfr-b bc h udc setup interrupt control register 0000 h f17a h urd0ic esfr-b bd h udc rx done0 interrupt control register 0000 h physical addr register name type 8-bit addr description reset value
c165h register set data sheet 453 2001-04-19 p r e l i m i n a r y - exc er pt - f17e h iomc0tic esfr-b bf h iom-2 channel0 tx interrupt control register 0000 h f180 h pecclic esfr-b c0 h pec channel link interrupt control register 0000 h f182 h iomc0ric esfr-b c1 h iom-2 channel0 rx interrupt control register 0000 h f184 h rtc_intic esfr-b c2 h rtc_int sub node interrupt register 0000 h f186 h xp0ic esfr-b c3 h x-bus peripheral 0 udc txwr interrupt control register 0000 h f18a h iomc1tic esfr-b c5 h iom-2 channel1 tx interrupt control register 0000 h f18c h abendic esfr-b c6 h asc autobaud end interrupt control register 0000 h f18e h xp1ic esfr-b c7 h x-bus peripheral 1 register 0000 h f192 h iomc1ric esfr-b c9 h iom-2 channel1 rx interrupt control register 0000 h f194 h abstic esfr-b ca h asc autobaud start interrupt control register 0000 h f196 h xp2ic esfr-b cb h x-bus peripheral 2 iom-2 io interrupt control register 0000 h f19a h res6ic esfr-b cd h reserved 0000 h f19c h s0tbic esfr-b ce h serial channel 0 transmit buffer ic register 0000 h f19e h xp3ic esfr-b cf h x-bus peripheral 3 pll/rtc interrupt control register 0000 h f1c0 h exicon esfr-b e0 h external interrupt control register 0000 h f1c2 h odp2 esfr-b e1 h port 2 open drain control register 0000 h f1c6 h odp3 esfr-b e3 h port 3 open drain control register 0000 h f1c8 h rtcisnc esfr-b e4 h rtc interrupt sub node control register 0000 h f1ca h odp4 esfr-b e5 h port 4 open drain control register 00 h f1cc h rtccon esfr-b e6 h rtc control register 00 h f1ce h odp6 esfr-b e7 h port 6 open drain control register 00 h f1d0 h syscon2 esfr-b e8 h system configuration register 2/clock control 0000 h f1d2 h odp7 esfr-b e9 h port 7 open drain control register 00 h f1d4 h syscon3 esfr-b ea h system configuration register 3/periph. managem. 0000 h f1d6 h reserved esfr-b eb h reserved - do not use 0000 h f1d8 h reserved esfr-b ec h reserved - do not use 0000 h f1da h exisel esfr-b ed h external interrupt select register 0000 h f1dc h syscon1 esfr-b ee h system configuration register 1/sleep mode 0000 h f1de h isnc esfr-b ef h interrupt sub node control register 0000 h fe00 h dpp0 sfr 00 h cpu data page pointer 0 register (10 bits) 0000 h fe02 h dpp1 sfr 01 h cpu data page pointer 1 register (10 bits) 0001 h fe04 h dpp2 sfr 02 h cpu data page pointer 2 register (10 bits) 0002 h fe06 h dpp3 sfr 03 h cpu data page pointer 3 register (10 bits) 0003 h physical addr register name type 8-bit addr description reset value
c165h register set data sheet 454 2001-04-19 p r e l i m i n a r y - exc er p t - fe08 h csp sfr 04 h cpu code segment pointer register (8 bits) 0000 h fe0a h emucon sfr 05 h emulation control register 2) xxxx h fe0c h mdh sfr 06 h cpu multiply divide register - high word 0000 h fe0e h mdl sfr 07 h cpu multiply divide register - low word 0000 h fe10 h cp sfr 08 h cpu context pointer register fc00 h fe12 h sp sfr 09 h cpu system stack pointer register fc00 h fe14 h stkov sfr 0a h cpu stack overflow pointer register fa00 h fe16 h stkun sfr 0b h cpu stack underflow pointer register fc00 h fe18 h addrsel1 sfr 0c h address select register 1 0000 h fe1a h addrsel2 sfr 0d h address select register 2 0000 h fe1c h addrsel3 sfr 0e h address select register 3 0000 h fe1e h addrsel4 sfr 0f h address select register 4 0000 h fe22 h odp0h sfr 11 h port 0 open drain control register high 0000 h fe24 h odp1l sfr 12 h port 1 open drain control register low 0000 h fe26 h odp1h sfr 13 h port 1 open drain control register high 0000 h fe40 h t2 sfr 20 h gpt1 timer 2 register 0000 h fe42 h t3 sfr 21 h gpt1 timer 3 register 0000 h fe44 h t4 sfr 22 h gpt1 timer 4 register 0000 h fe46 h t5 sfr 23 h gpt2 timer 5 register 0000 h fe48 h t6 sfr 24 h gpt2 timer 6 register 0000 h fe4a h caprel sfr 25 h gpt1/2 capture / reload register 0000 h fe4c h gptclc sfr 26 h gpt1/2 clock control register 0000 h fe60 h p0lpudsel sfr 30 h port 0 low pull-up/down select register xxff h fe62 h p0hpudsel sfr 31 h port 0 high pull-up/down select register xxff h fe64 h p0lpuden sfr 32 h port 0 low pull switch on/off register xxff fe66 h p0hpuden sfr 33 h port 0 high pull switch on/off register xxff h fe68 h p0lphen sfr 34 h port 0 low pin hold enable register 0000 h fe6a h p0hphen sfr 35 h port 0 high pin hold enable register 0000 h fe6c h p1lpudsel sfr 36 h port 1 low pull-up/down select register 0000 h fe6e h p1hpudsel sfr 37 h port 1 high pull-up/down select register 0000 h fe70 h p1lpuden sfr 38 h port 1 low pull switch on/off register 0000 h fe72 h p1hpuden sfr 39 h port 1 high pull switch on/off register 0000 h fe74 h p1lphen sfr 3a h port 1 low pin hold enable register 0000 h fe76 h p1hphen sfr 3b h port 1 high pin hold enable register 0000 h fe78 h p2pudsel sfr 3c h port 2 pull-up/down select register 0000 h physical addr register name type 8-bit addr description reset value
c165h register set data sheet 455 2001-04-19 p r e l i m i n a r y - exc er pt - fe7a h p2puden sfr 3d h port 2 pull switch on/off register 0000 h fe7c h p2phen sfr 3e h port 2 pin hold enable register 0000 h fe7e h p3pudsel sfr 3f h port 3 pull-up/down select register 0000 h fe80 h p3puden sfr 40 h port 3 pull switch on/off register 0000 h fe82 h p3phen sfr 41 h port 3 pin hold enable register 0000 h fe84 h p4pudsel sfr 42 h port 4 pull-up/down select register 0000 h fe86 h p4puden sfr 43 h port 4 pull switch on/off register 0000 h fe88 h p4phen sfr 44 h port 4 pin hold enable register 0000 h fe90 h p6pudsel sfr 48 h port 6 pull-up/down select register 0000 h fe92 h p6puden sfr 49 h port 6 pull switch on/off register 0000 h fe94 h p6phen sfr 4a h port 6 pin hold enable register 0000 h fe96 h p7pudsel sfr 4b h port 7 pull-up/down select register 0000 h fe98 h p7puden sfr 4c h port 7 pull switch on/off register 0000 h fe9a h p7phen sfr 4d h port 7 pin hold enable register 0000 h feaa h s0pmw sfr 55 h asc irda pmw control register 0000 h feae h wdt sfr 57 h watchdog timer register (ro) 0000 h feb0 h s0tbuf sfr 58 h serial channel 0 transmit buffer register (wo) 0000 h feb2 h s0rbuf sfr 59 h serial channel 0 receive buffer register (ro) xxxx h feb4 h s0bg sfr 5a h serial channel 0 baud rate generator reload register 0000 h feb6 h s0fdv sfr 5b h asc fractional divide register 0000 h fec0 h pecc0 sfr 60 h pec channel 0 control register 0000 h fec2 h pecc1 sfr 61 h pec channel 1 control register 0000 h fec4 h pecc2 sfr 62 h pec channel 2 control register 0000 h fec6 h pecc3 sfr 63 h pec channel 3 control register 0000 h fec8 h pecc4 sfr 64 h pec channel 4 control register 0000 h feca h pecc5 sfr 65 h pec channel 5 control register 0000 h fecc h pecc6 sfr 66 h pec channel 6 control register 0000 h fece h pecc7 sfr 67 h pec channel 7 control register 0000 h fed0 h pecsn0 sfr 68 h pec segment no register fed2 h pecsn1 sfr 69 h pec segment no register fed4 h pecsn2 sfr 6a h pec segment no register fed6 h pecsn3 sfr 6b h pec segment no register fed8 h pecsn4 sfr 6c h pec segment no register feda h pecsn5 sfr 6d h pec segment no register fedc h pecsn6 sfr 6e h pec segment no register physical addr register name type 8-bit addr description reset value
c165h register set data sheet 456 2001-04-19 p r e l i m i n a r y - exc er p t - fede h pecsn7 sfr 6f h pec segment no register fef0 h pecxc0 sfr 78 h pec channel 0 extended control register fef2 h pecxc2 sfr 79 h pec channel 2 extended control register fef8 h abs0con sfr 7c h asc autobaud control register 0000 h fefe h abstat sfr 7f h asc autobaud status register 0000 h ff00 h p0l sfr-b 80 h port 0 low register (lower half) 00 h ff02 h p0h sfr-b 81 h port 0 high register (upper half) 00 h ff04 h p1l sfr-b 82 h port 1 low register (lower half) 00 h ff06 h p1h sfr-b 83 h port 1 high register (upper half) 00 h ff0c h buscon0 sfr-b 86 h bus configuration register 0 0000 h ff0e h mdc sfr-b 87 h cpu multiply divide control register 0000 h ff10 h psw sfr-b 88 h cpu program status word 0000 h ff12 h syscon sfr-b 89 h cpu system configuration register 0xx0 h ff14 h buscon1 sfr-b 8a h bus configuration register 1 0000 h ff16 h buscon2 sfr-b 8b h bus configuration register 2 0000 h ff18 h buscon3 sfr-b 8c h bus configuration register 3 0000 h ff1a h buscon4 sfr-b 8d h bus configuration register 4 0000 h ff1c h zeros sfr-b 8e h constant value 0sregister' 0000 h ff1e h ones sfr-b 8f h constant value 1sregister' ffff h ff40 h t2con sfr-b a0 h gpt1 timer 2 control register 0000 h ff42 h t3con sfr-b a1 h gpt1 timer 3 control register 0000 h ff44 h t4con sfr-b a2 h gpt1 timer 4 control register 0000 h ff46 h t5con sfr-b a3 h gpt2 timer 5 control register 0000 h ff48 h t6con sfr-b a4 h gpt2 timer 6 control register 0000 h ff60 h t2ic sfr-b b0 h gpt1 timer 2 interrupt control register 0000 h ff62 h t3ic sfr-b b1 h gpt1 timer 3 interrupt control register 0000 h ff64 h t4ic sfr-b b2 h gpt1 timer 4 interrupt control register 0000 h ff66 h t5ic sfr-b b3 h gpt2 timer 5 interrupt control register 0000 h ff68 h t6ic sfr-b b4 h gpt2 timer 6 interrupt control register 0000 h ff6a h cric sfr-b b5 h gpt2 caprel interrupt control register 0000 h ff6c h s0tic sfr-b b6 h serial channel 0 transmit interrupt control register 0000 h ff6e h s0ric sfr-b b7 h serial channel 0 receive interrupt control register 0000 h ff70 h s0eic sfr-b b8 h serial channel 0 error interrupt control register 0000 h ff72 h ssctic sfr-b b9 h ssc transmit interrupt control register 0000 h physical addr register name type 8-bit addr description reset value
c165h register set data sheet 457 2001-04-19 p r e l i m i n a r y - exc er pt - ff74 h sscric sfr-b ba h ssc receive interrupt control register 0000 h ff76 h ssceic sfr-b bb h ssc error interrupt control register 0000 h ff78 h urd3ic sfr-b bc h udc rx done3 interrupt control register 0000 h ff7a h urd4ic sfr-b bd h udc rx done4 interrupt control register 0000 h ff7c h urd5ic sfr-b be h udc rx done5 interrupt control register 0000 h ff7e h urd6ic sfr-b bf h udc rx done6 interrupt control register 0000 h ff80 h urd7ic sfr-b c0 h udc rx done7 interrupt control register 0000 h ff82 h utd0ic sfr-b c1 h udc tx done0 interrupt control register 0000 h ff84 h utd1ic sfr-b c2 h udc tx done1 interrupt control register 0000 h ff86 h utd2ic sfr-b c3 h udc tx done2 interrupt control register 0000 h ff88 h fei0ic sfr-b c4 h fast external interrupt 0 control register 0000 h ff8a h fei1ic sfr-b c5 h fast external interrupt 1 control register 0000 h ff8c h fei2ic sfr-b c6 h fast external interrupt 2 control register 0000 h ff8e h fei3ic sfr-b c7 h fast external interrupt 3 control register 0000 h ff90 h fei4ic sfr-b c8 h fast external interrupt 4 control register 0000 h ff92 h fei5ic sfr-b c9 h fast external interrupt 5 control register 0000 h ff94 h fei6ic sfr-b ca h fast external interrupt 6 control register 0000 h ff96 h fei7ic sfr-b cb h fast external interrupt 7 control register 0000 h ff98 h res4ic sfr-b cb h reserved 0000 h ff9a h iomioic sfr-b cd h iom-2 io interrupt control register 0000 h ff9c h urd2ic sfr-b ce h udc rx done2 interrupt control register 0000 h ff9e h urd1ic sfr-b cf h udc rx done1 interrupt control register 0000 h ffa8 h clisnc sfr-b d4 h the channel link interrupt subnode register 0000 h ffaa h focon sfr-b d5 h frequency output control register 0000 h ffac h tfr sfr-b d6 h trap flag register 0000 h ffae h wdtcon sfr-b d7 h watchdog timer control register 000x h ffb0 h s0con sfr-b d8 h serial channel 0 control register 0000 h ffb2 h ssccon sfr-b d9 h ssc control register 0000 h ffba h s0clc sfr-b dd h asc clock control register 0000 h ffc0 h p2 sfr-b e0 h port 2 register 0000 h ffc2 h dp2 sfr-b e1 h port 2 direction control register 0000 h ffc4 h p3 sfr-b e2 h port 3 register 0000 h ffc6 h dp3 sfr-b e3 h port 3 direction control register 0000 h ffc8 h p4 sfr-b e4 h port 4 register (8 bits) 00 h ffca h dp4 sfr-b e5 h port 4 direction control register 00 h physical addr register name type 8-bit addr description reset value
c165h register set data sheet 458 2001-04-19 p r e l i m i n a r y - exc er p t - 21.4 special function registers ordered by name the following table lists all sfrs which are implemented in the c165h ordered by their name. bit- addressable sfrs are marked with the letter ? b ? in column ? type ? . sfrs within the extended sfr-space (esfrs) are marked with the letter ? e ? in column ? type ? . table 76 registers ordered by name ffcc h p6 sfr-b e6 h port 6 register (8 bits) 00 h ffce h dp6 sfr-b e7 h port 6 direction control register 00 h ffd0 h p7 sfr-b e8 h port 7 register (8 bits) 00 h ffd2 h dp7 sfr-b e9 h port 7 direction control register 00 h 1) the dtidr register is a data register which is used by advanced real time operating systems to store the task id of the active task. it is used for hardware trigger events in the ocds. 2) the emucon register is a reserved test register and is not to be used by other software. register name phys. addr type 8-bit addr description reset value abendic f18c h esfr-b c6 h asc autobaud end interrupt control register 0000 h abs0con fef8 h sfr 7c h asc autobaud control register 0000 h abstat fefe h sfr 7f h asc autobaud status register 0000 h abstic f194 h esfr-b ca h asc autobaud start interrupt control register 0000 h addrsel1 fe18 h sfr 0c h address select register 1 0000 h addrsel2 fe1a h sfr 0d h address select register 2 0000 h addrsel3 fe1c h sfr 0e h address select register 3 0000 h addrsel4 fe1e h sfr 0f h address select register 4 0000 h buscon0 ff0c h sfr-b 86 h bus configuration register 0 0000 h buscon1 ff14 h sfr-b 8a h bus configuration register 1 0000 h buscon2 ff16 h sfr-b 8b h bus configuration register 2 0000 h buscon3 ff18 h sfr-b 8c h bus configuration register 3 0000 h buscon4 ff1a h sfr-b 8d h bus configuration register 4 0000 h caprel fe4a h sfr 25 h gpt1/2 capture / reload register 0000 h clisnc ffa8 h sfr-b d4 h the channel link interrupt subnode register 0000 h cp fe10 h sfr 08 h cpu context pointer register fc00 h cric ff6a h sfr-b b5 h gpt2 caprel interrupt control register 0000 h csp fe08 h sfr 04 h cpu code segment pointer register (8 bits) 0000 h dp0h f102 h esfr-b 81 h p0h direction control register 00 h dp0l f100 h esfr-b 80 h p0l direction control register 00 h physical addr register name type 8-bit addr description reset value
c165h register set data sheet 459 2001-04-19 p r e l i m i n a r y - exc er pt - dp1h f106 h esfr-b 83 h p1h direction control register 00 h dp1l f104 h esfr-b 82 h p1l direction control register 00 h dp2 ffc2 h sfr-b e1 h port 2 direction control register 0000 h dp3 ffc6 h sfr-b e3 h port 3 direction control register 0000 h dp4 ffca h sfr-b e5 h port 4 direction control register 00 h dp6 ffce h sfr-b e7 h port 6 direction control register 00 h dp7 ffd2 h sfr-b e9 h port 7 direction control register 00 h dpp0 fe00 h sfr 00 h cpu data page pointer 0 register (10 bits) 0000 h dpp1 fe02 h sfr 01 h cpu data page pointer 1 register (10 bits) 0001 h dpp2 fe04 h sfr 02 h cpu data page pointer 2 register (10 bits) 0002 h dpp3 fe06 h sfr 03 h cpu data page pointer 3 register (10 bits) 0003 h dtidr f0d8 h esfr 6c h task id register 0000 h emucon fe0a h sfr 05 h emulation control register xxxx h exicon f1c0 h esfr-b e0 h external interrupt control register 0000 h exisel f1da h esfr-b ed h external interrupt select register 0000 h fei0ic ff88 h sfr-b c4 h fast external interrupt 0 control register 0000 h fei1ic ff8a h sfr-b c5 h fast external interrupt 1 control register 0000 h fei2ic ff8c h sfr-b c6 h fast external interrupt 2 control register 0000 h fei3ic ff8e h sfr-b c7 h fast external interrupt 3 control register 0000 h fei4ic ff90 h sfr-b c8 h fast external interrupt 4 control register 0000 h fei5ic ff92 h sfr-b c9 h fast external interrupt 5 control register 0000 h fei6ic ff94 h sfr-b ca h fast external interrupt 6 control register 0000 h fei7ic ff96 h sfr-b cb h fast external interrupt 7 control register 0000 h focon ffaa h sfr-b d5 h frequency output control register 0000 h gptclc fe4c h sfr 26 h gpt1/2 clock control register 0000 h idchip f07c h esfr 3e h identifier 0503 h idmanuf f07e h esfr 3f h identifier 1824 h idmem f07a h esfr 3d h identifier 0000 h idmem2 f076 h esfr 3b h identifier 0000 h idprog f078 h esfr 3c h identifier 0000 h iomc0ric f182 h esfr-b c1 h iom-2 channel0 rx interrupt control register 0000 h iomc0tic f17e h esfr-b bf h iom-2 channel0 tx interrupt control register 0000 h iomc1ric f192 h esfr-b c9 h iom-2 channel1 rx interrupt control register 0000 h iomc1tic f18a h esfr-b c5 h iom-2 channel1 tx interrupt control register 0000 h iomioic ff9a h sfr-b cd h iom-2 io interrupt control register 0000 h register name phys. addr type 8-bit addr description reset value
c165h register set data sheet 460 2001-04-19 p r e l i m i n a r y - exc er p t - isnc f1de h esfr-b ef h interrupt sub node control register 0000 h mdc ff0e h sfr-b 87 h cpu multiply divide control register 0000 h mdh fe0c h sfr 06 h cpu multiply divide register - high word 0000 h mdl fe0e h sfr 07 h cpu multiply divide register - low word 0000 h odp0h fe22 h sfr 11 h port 0 open drain control register high 0000 h odp1h fe26 h sfr 13 h port 1 open drain control register high 0000 h odp1l fe24 h sfr 12 h port 1 open drain control register low 0000 h odp2 f1c2 h esfr-b e1 h port 2 open drain control register 0000 h odp3 f1c6 h esfr-b e3 h port 3 open drain control register 0000 h odp4 f1ca h esfr-b e5 h port 4 open drain control register 00 h odp6 f1ce h esfr-b e7 h port 6 open drain control register 00 h odp7 f1d2 h esfr-b e9 h port 7 open drain control register 00 h ones ff1e h sfr-b 8f h constant value 1sregister' ffff h p0h ff02 h sfr-b 81 h port 0 high register (upper half) 00 h p0hphen fe6a h sfr 35 h port 0 high pin hold enable register 0000 h p0hpuden fe66 h sfr 33 h port 0 high pull switch on/off register xxff h p0hpudsel fe62 h sfr 31 h port 0 high pull-up/down select register xxff h p0l ff00 h sfr-b 80 h port 0 low register (lower half) 00 h p0lphen fe68 h sfr 34 h port 0 low pin hold enable register 0000 h p0lpuden fe64 h sfr 32 h port 0 low pull switch on/off register xxff h p0lpudsel fe60 h sfr 30 h port 0 low pull-up/down select register xxff h p1h ff06 h sfr-b 83 h port 1 high register (upper half) 00 h p1hphen fe76 h sfr 3b h port 1 high pin hold enable register 0000 h p1hpuden fe72 h sfr 39 h port 1 high pull switch on/off register 0000 h p1hpudsel fe6e h sfr 37 h port 1 high pull-up/down select register 0000 h p1l ff04 h sfr-b 82 h port 1 low register (lower half) 00 h p1lphen fe74 h sfr 3a h port 1 low pin hold enable register 0000 h p1lpuden fe70 h sfr 38 h port 1 low pull switch on/off register 0000 h p1lpudsel fe6c h sfr 36 h port 1 low pull-up/down select register 0000 h p2 ffc0 h sfr-b e0 h port 2 register 0000 h p2phen fe7c h sfr 3e h port 2 pin hold enable register 0000 h p2puden fe7a h sfr 3d h port 2 pull switch on/off register 0000 h p2pudsel fe78 h sfr 3c h port 2 pull-up/down select register 0000 h p3 ffc4 h sfr-b e2 h port 3 register 0000 h p3phen fe82 h sfr 41 h port 3 pin hold enable register 0000 h register name phys. addr type 8-bit addr description reset value
c165h register set data sheet 461 2001-04-19 p r e l i m i n a r y - exc er pt - p3puden fe80 h sfr 40 h port 3 pull switch on/off register 0000 h p3pudsel fe7e h sfr 3f h port 3 pull-up/down select register 0000 h p4 ffc8 h sfr-b e4 h port 4 register (8 bits) 00 h p4phen fe88 h sfr 44 h port 4 pin hold enable register 0000 h p4puden fe86 h sfr 43 h port 4 pull switch on/off register 0000 h p4pudsel fe84 h sfr 42 h port 4 pull-up/down select register 0000 h p6 ffcc h sfr-b e6 h port 6 register (8 bits) 00 h p6phen fe94 h sfr 4a h port 6 pin hold enable register 0000 h p6puden fe92 h sfr 49 h port 6 pull switch on/off register 0000 h p6pudsel fe90 h sfr 48 h port 6 pull-up/down select register 0000 h p7 ffd0 h sfr-b e8 h port 7 register (8 bits) 00 h p7phen fe9a h sfr 4d h port 7 pin hold enable register 0000 h p7puden fe98 h sfr 4c h port 7 pull switch on/off register 0000 h p7pudsel fe96 h sfr 4b h port 7 pull-up/down select register 0000 h pecc0 fec0 h sfr 60 h pec channel 0 control register 0000 h pecc1 fec2 h sfr 61 h pec channel 1 control register 0000 h pecc2 fec4 h sfr 62 h pec channel 2 control register 0000 h pecc3 fec6 h sfr 63 h pec channel 3 control register 0000 h pecc4 fec8 h sfr 64 h pec channel 4 control register 0000 h pecc5 feca h sfr 65 h pec channel 5 control register 0000 h pecc6 fecc h sfr 66 h pec channel 6 control register 0000 h pecc7 fece h sfr 67 h pec channel 7 control register 0000 h pecclic f180 h esfr-b c0 h pec channel link interrupt control register 0000 h pecsn0 fed0 h sfr 68 h pec segment no register pecsn1 fed2 h sfr 69 h pec segment no register pecsn2 fed4 h sfr 6a h pec segment no register pecsn3 fed6 h sfr 6b h pec segment no register pecsn4 fed8 h sfr 6c h pec segment no register pecsn5 feda h sfr 6d h pec segment no register pecsn6 fedc h sfr 6e h pec segment no register pecsn7 fede h sfr 6f h pec segment no register pecxc0 fef0 h sfr 78 h pec channel 0 extended control register pecxc2 fef2 h sfr 79 h pec channel 2 extended control register psw ff10 h sfr-b 88 h cpu program status word 0000 h r0 sfr-b f0 h general purpose register 0 uuuu h register name phys. addr type 8-bit addr description reset value
c165h register set data sheet 462 2001-04-19 p r e l i m i n a r y - exc er p t - r0 esfr-b f0 h general purpose register 0 uuuu h r1 sfr-b f1 h general purpose register 1 uuuu h r1 esfr-b f1 h general purpose register 1 uuuu h r10 esfr-b fa h general purpose register 10 uuuu h r10 sfr-b fa h general purpose register 10 uuuu h r11 sfr-b fb h general purpose register 11 uuuu h r11 esfr-b fb h general purpose register 11 uuuu h r12 sfr-b fc h general purpose register 12 uuuu h r12 esfr-b fc h general purpose register 12 uuuu h r13 sfr-b fd h general purpose register 13 uuuu h r13 esfr-b fd h general purpose register 13 uuuu h r14 sfr-b fe h general purpose register 14 uuuu h r14 esfr-b fe h general purpose register 14 uuuu h r15 esfr-b ff h general purpose register 15 uuuu h r15 sfr-b ff h general purpose register 15 uuuu h r2 sfr-b f2 h general purpose register 2 uuuu h r2 esfr-b f2 h general purpose register 2 uuuu h r3 sfr-b f3 h general purpose register 3 uuuu h r3 esfr-b f3 h general purpose register 3 uuuu h r4 esfr-b f4 h general purpose register 4 uuuu h r4 sfr-b f4 h general purpose register 4 uuuu h r5 esfr-b f5 h general purpose register 5 uuuu h r5 sfr-b f5 h general purpose register 5 uuuu h r6 esfr-b f6 h general purpose register 6 uuuu h r6 sfr-b f6 h general purpose register 6 uuuu h r7 esfr-b f7 h general purpose register 7 uuuu h r7 sfr-b f7 h general purpose register 7 uuuu h r8 sfr-b f8 h general purpose register 8 uuuu h r8 esfr-b f8 h general purpose register 8 uuuu h r9 sfr-b f9 h general purpose register 9 uuuu h r9 esfr-b f9 h general purpose register 9 uuuu h res4ic ff98 h sfr-b cb h reserved 0000 h res6ic f19a h esfr-b cd h reserved 0000 h reserved f1d6 h esfr-b eb h reserved - do not use 0000 h reserved f1d8 h esfr-b ec h reserved - do not use 0000 h register name phys. addr type 8-bit addr description reset value
c165h register set data sheet 463 2001-04-19 p r e l i m i n a r y - exc er pt - rp0h f108 h esfr-b 84 h system startup configuration register (ro) xx h rtc_intic f184 h esfr-b c2 h rtc_int sub node interrupt register 0000 h rtcclc f0c8 h esfr 64 h rtc clock control register 0000 h rtccon f1cc h esfr-b e6 h rtc control register 00 h rtch f0d6 h esfr 6b h rtc timer register high n h rtcisnc f1c8 h esfr-b e4 h rtc interrupt sub node control register 0000 h rtcl f0d4 h esfr 6a h rtc timer register low n h rtcrelh f0ce h esfr 67 h rtc timer reload register high 0000 h rtcrell f0cc h esfr 66 h rtc timer reload register low 0000 h s0bg feb4 h sfr 5a h serial channel 0 baud rate generator reload register 0000 h s0clc ffba h sfr-b dd h asc clock control register 0000 h s0con ffb0 h sfr-b d8 h serial channel 0 control register 0000 h s0eic ff70 h sfr-b b8 h serial channel 0 error interrupt control register 0000 h s0fdv feb6 h sfr 5b h asc fractional divide register 0000 h s0pmw feaa h sfr 55 h asc irda pmw control register 0000 h s0rbuf feb2 h sfr 59 h serial channel 0 receive buffer register (ro) xxxx h s0ric ff6e h sfr-b b7 h serial channel 0 receive interrupt control register 0000 h s0tbic f19c h esfr-b ce h serial channel 0 transmit buffer ic register 0000 h s0tbuf feb0 h sfr 58 h serial channel 0 transmit buffer register (wo) 0000 h s0tic ff6c h sfr-b b6 h serial channel 0 transmit interrupt control register 0000 h scuslc f0c0 h esfr 60 h security level control register scusls f0c2 h esfr 61 h security level status register sp fe12 h sfr 09 h cpu system stack pointer register fc00 h sscbr f0b4 h esfr 5a h ssc baudrate register 0000 h sscclc f0b6 h esfr 5b h ssc clock control register 0000 h ssccon ffb2 h sfr-b d9 h ssc control register 0000 h ssceic ff76 h sfr-b bb h ssc error interrupt control register 0000 h sscrb f0b2 h esfr 59 h ssc receive buffer (ro) xxxx h sscric ff74 h sfr-b ba h ssc receive interrupt control register 0000 h ssctb f0b0 h esfr 58 h ssc transmit buffer (wo) 0000 h ssctic ff72 h sfr-b b9 h ssc transmit interrupt control register 0000 h stkov fe14 h sfr 0a h cpu stack overflow pointer register fa00 h stkun fe16 h sfr 0b h cpu stack underflow pointer register fc00 h register name phys. addr type 8-bit addr description reset value
c165h register set data sheet 464 2001-04-19 p r e l i m i n a r y - exc er p t - syscon ff12 h sfr-b 89 h cpu system configuration register 0xx0 h syscon1 f1dc h esfr-b ee h system configuration register 1/sleep mode 0000 h syscon2 f1d0 h esfr-b e8 h system configuration register 2/clock control 0000 h syscon3 f1d4 h esfr-b ea h system configuration register 3/periph. managem. 0000 h t14 f0d2 h esfr 69 h timer 14 register n h t14rel f0d0 h esfr 68 h timer 14 reload register n h t2 fe40 h sfr 20 h gpt1 timer 2 register 0000 h t2con ff40 h sfr-b a0 h gpt1 timer 2 control register 0000 h t2ic ff60 h sfr-b b0 h gpt1 timer 2 interrupt control register 0000 h t3 fe42 h sfr 21 h gpt1 timer 3 register 0000 h t3con ff42 h sfr-b a1 h gpt1 timer 3 control register 0000 h t3ic ff62 h sfr-b b1 h gpt1 timer 3 interrupt control register 0000 h t4 fe44 h sfr 22 h gpt1 timer 4 register 0000 h t4con ff44 h sfr-b a2 h gpt1 timer 4 control register 0000 h t4ic ff64 h sfr-b b2 h gpt1 timer 4 interrupt control register 0000 h t5 fe46 h sfr 23 h gpt2 timer 5 register 0000 h t5con ff46 h sfr-b a3 h gpt2 timer 5 control register 0000 h t5ic ff66 h sfr-b b3 h gpt2 timer 5 interrupt control register 0000 h t6 fe48 h sfr 24 h gpt2 timer 6 register 0000 h t6con ff48 h sfr-b a4 h gpt2 timer 6 control register 0000 h t6ic ff68 h sfr-b b4 h gpt2 timer 6 interrupt control register 0000 h tfr ffac h sfr-b d6 h trap flag register 0000 h ucfgvic f16e h esfr-b b7 h udc config val interrupt control register 0000 h ulcdic f176 h esfr-b bb h udc load config done interrupt control register 0000 h urd0ic f17a h esfr-b bd h udc rx done0 interrupt control register 0000 h urd1ic ff9e h sfr-b cf h udc rx done1 interrupt control register 0000 h urd2ic ff9c h sfr-b ce h udc rx done2 interrupt control register 0000 h urd3ic ff78 h sfr-b bc h udc rx done3 interrupt control register 0000 h urd4ic ff7a h sfr-b bd h udc rx done4 interrupt control register 0000 h urd5ic ff7c h sfr-b be h udc rx done5 interrupt control register 0000 h urd6ic ff7e h sfr-b bf h udc rx done6 interrupt control register 0000 h urd7ic ff80 h sfr-b c0 h udc rx done7 interrupt control register 0000 h urxric f16a h esfr-b b5 h udc rxrr interrupt control register 0000 h usetic f178 h esfr-b bc h udc setup interrupt control register 0000 h register name phys. addr type 8-bit addr description reset value
c165h register set data sheet 465 2001-04-19 p r e l i m i n a r y - exc er pt - usofic f170 h esfr-b b8 h udc start of frame interrupt control register 0000 h ussic f174 h esfr-b ba h udc suspend interrupt control register 0000 h ussoic f172 h esfr-b b9 h udc suspend off interrupt control register 0000 h utd0ic ff82 h sfr-b c1 h udc tx done0 interrupt control register 0000 h utd1ic ff84 h sfr-b c2 h udc tx done1 interrupt control register 0000 h utd2ic ff86 h sfr-b c3 h udc tx done2 interrupt control register 0000 h utd3ic f160 h esfr-b b0 h udc tx done3 interrupt control register 0000 h utd4ic f162 h esfr-b b1 h udc tx done4 interrupt control register 0000 h utd5ic f164 h esfr-b b2 h udc tx done5 interrupt control register 0000 h utd6ic f166 h esfr-b b3 h udc tx done6 interrupt control register 0000 h utd7ic f168 h esfr-b b4 h udc tx done7 interrupt control register 0000 h utxric f16c h esfr-b b6 h udc txwr interrupt control register 0000 h wdt feae h sfr 57 h watchdog timer register (ro) 0000 h wdtcon ffae h sfr-b d7 h watchdog timer control register 000x h xadrs1 f014 h esfr 0a h xbus address select register 1 xadrs2 f016 h esfr 0b h xbus address select register 2 xadrs3 f018 h esfr 0c h xbus address select register 3 xadrs4 f01a h esfr 0d h xbus address select register 4 xadrs5 f01c h esfr 0e h xbus address select register 5 xadrs6 f01e h esfr 0f h xbus address select register 6 xbcon1 f114 h esfr-b 8a h xbus control register 1: iom-2 module 0000 h xbcon2 f116 h esfr-b 8b h xbus control register 2: reserved 0000 h xbcon3 f118 h esfr-b 8c h xbus control register 3: reserved 0000 h xbcon4 f11a h esfr-b 8d h xbus control register 4: reserved 0000 h xbcon5 f11c h esfr-b 8e h xbus control register 5: reserved 0000 h xbcon6 f11e h esfr-b 8f h xbus control register 6: reserved xp0ic f186 h esfr-b c3 h x-bus peripheral 0 udc txwr interrupt control register 0000 h xp1ic f18e h esfr-b c7 h x-bus peripheral 1 register 0000 h xp2ic f196 h esfr-b cb h x-bus peripheral 2 iom-2 io interrupt control register 0000 h xp3ic f19e h esfr-b cf h x-bus peripheral 3 pll/rtc interrupt control register 0000 h xpercon f024 h esfr 12 h xbus peripheral control register 0401 h zeros ff1c h sfr-b 8e h constant value 0sregister' 0000 h register name phys. addr type 8-bit addr description reset value
c165h register set data sheet 466 2001-04-19 p r e l i m i n a r y - exc er p t - 21.5 special notes pec pointer registers the source and destination pointers for the peripheral event controller are mapped to a special area within the internal ram. pointers that are not occupied by the pec may therefore be used like normal ram. during power down mode or any warm reset the pec pointers are preserved. the pec and its registers are described in chapter ?interrupt and trap functions?. gpr access in the esfr area the locations 00?f000h...00?f01eh within the esfr area are reserved and allow to access the current register bank via short register addressing modes. the gprs are mirrored to the esfr area which allows access to the current register bank even after switching register spaces (see example below). mov r5, dp3 ;gpr access via sfr area extr #1 mov r5, odp3 ;gpr access via esfr area writing bytes to sfrs all special function registers may be accessed wordwise or bytewise (some of them even bitwise). reading bytes from word sfrs is a non-critical operation. however, when writing bytes to word sfrs the complementary byte of the respective sfr is cleared with the write operation.
c165h instruction set summary data sheet 467 2001-04-19 p r e l i m i n a r y - exc er pt - 22 instruction set summary this chapter briefly summarizes the c165h's instructions ordered by instruction classes. this provides a basic understanding of the c165h?s instruction set, the power and versatility of the instructions and their general usage. a detailed description of each single instruction, including its operand data type, condition flag settings, addressing modes, length (number of bytes) and object code format is provided in the ?instruction set manual? for the c16x family. this manual also provides tables ordering the instructions according to various criteria, to allow quick references. summary of instruction classes grouping the various instruction into classes aids in identifying similar instructions (eg. shr, ror) and variations of certain instructions (eg. add, addb). this provides an easy access to the possibilities and the power of the instructions of the c165h. note: the used mnemonics refer to the detailled description. arithmetic instructions  addition of two words or bytes: add addb  addition with carry of two words or bytes: addc addcb  subtraction of two words or bytes: sub subb  subtraction with carry of two words or bytes: subc subcb 16 * 16 bit signed or unsigned multiplication: mul mulu  16/16 bit signed or unsigned division: div divu  32/16 bit signed or unsigned division: divl divlu  1's complement of a word or byte: cpl cplb  2's complement (negation) of a word or byte: neg negb logical instructions  bitwise anding of two words or bytes: and andb  bitwise oring of two words or bytes: or orb  bitwise xoring of two words or bytes: xor xorb compare and loop control instructions  comparison of two words or bytes: cmp cmpb  comparison of two words with post-increment by either 1 or 2: cmpi1 cmpi2  comparison of two words with post-decrement by either 1 or 2: cmpd1 cmpd2
c165h instruction set summary data sheet 468 2001-04-19 p r e l i m i n a r y - exc er p t - boolean bit manipulation instructions  manipulation of a maskable bit field in either the high or the low byte of a word: bfldh bfldl  setting a single bit (to ?1?): bset  clearing a single bit (to ?0?): bclr  movement of a single bit: bmov  movement of a negated bit: bmovn  anding of two bits: band  oring of two bits: bor  xoring of two bits: bxor  comparison of two bits: bcmp shift and rotate instructions  shifting right of a word: shr  shifting left of a word: shl  rotating right of a word: ror  rotating left of a word: rol  arithmetic shifting right of a word (sign bit shifting): ashr prioritize instruction  determination of the number of shift cycles required to normalize a word operand (floating point support): prior data movement instructions  standard data movement of a word or byte: mov movb  data movement of a byte to a word location with either sign or zero byte extension: movbs movbz note: the data movement instructions can be used with a big number of different addressing modes including indirect addressing and automatic pointer in-/ decrementing. system stack instructions  pushing of a word onto the system stack: push  popping of a word from the system stack: pop  saving of a word on the system stack, and then updating the old word with a new value (provided for register bank switching): scxt
c165h instruction set summary data sheet 469 2001-04-19 p r e l i m i n a r y - exc er pt - jump instructions  conditional jumping to an either absolutely, indirectly, or relatively addressed target instruction within the current code segment: jmpa jmpi jmpr  unconditional jumping to an absolutely addressed target instruction within any code segment: jmps  conditional jumping to a relatively addressed target instruction within the current code segment depending on the state of a selectable bit: jb jnb  conditional jumping to a relatively addressed target instruction within the current code segment depending on the state of a selectable bit with a post-inversion of the tested bit in case of jump taken (semaphore support): jbc jnbs call instructions  conditional calling of an either absolutely or indirectly addressed subroutine within the current code segment: calla calli  unconditional calling of a relatively addressed subroutine within the current code segment: callr  unconditional calling of an absolutely addressed subroutine within any code segment: calls  unconditional calling of an absolutely addressed subroutine within the current code segment plus an additional pushing of a selectable register onto the system stack: pcall  unconditional branching to the interrupt or trap vector jump table in code segment 0: trap return instructions  returning from a subroutine within the current code segment: ret  returning from a subroutine within any code segment: rets  returning from a subroutine within the current code segment plus an additional popping of a selectable register from the system stack: retp  returning from an interrupt service routine: reti
c165h instruction set summary data sheet 470 2001-04-19 p r e l i m i n a r y - exc er p t - system control instructions  resetting the c165h via software: srst  entering the idle mode: idle  entering the power down mode: pwrdn  servicing the watchdog timer: srvwdt  disabling the watchdog timer: diswdt  signifying the end of the initialization routine (pulls pin rstout high, and disables the effect of any later execution of a diswdt instruction): einit miscellaneous  null operation which requires 2 bytes of storage and the minimum time for execution: nop  definition of an unseparable instruction sequence: atomic  switch ?reg?, ?bitoff? and ?bitaddr? addressing modes to the extended sfr space: extr  override the dpp addressing scheme using a specific data page instead of the dpps, and optionally switch to esfr space: extp extpr  override the dpp addressing scheme using a specific segment instead of the dpps, and optionally switch to esfr space: exts extsr note: the atomic and ext* instructions provide support for uninterruptable code sequences eg. for semaphore operations. they also support data addressing beyond the limits of the current dpps (except atomic), which is advantageous for bigger memory models in high level languages. refer to chapter ?system programming? for examples. protected instructions some instructions of the c165h which are critical for the functionality of the controller are implemented as so-called protected instructions. these protected instructions use the maximum instruction format of 32 bits for decoding, while the regular instructions only use a part of it (eg. the lower 8 bits) with the other bits providing additional information like involved registers. decoding all 32 bits of a protected doubleword instruction increases the security in cases of data distortion during instruction fetching. critical operations like a software reset are therefore only executed if the complete instruction is decoded without an error. this enhances the safety and reliability of a microcontroller system.
c165h ac/dc characteristics data sheet 471 2001-04-19 p r e l i m i n a r y - exc er pt - 23 ac/dc characteristics 23.1 absolute maximum ratings  storage temperature ( t st ) -65 to +150 c  voltage on v dd pins with respect to ground ( v ss ) -0.5 to + 4.0 v  voltage on any pin with respect to ground ( v ss ) (except v dd , v ss , xtal pins) -0.5 to 5.5 v  absolute maximum total i/o current 250 ma  absolute maximum current on any pin, sink or source 10 ma stresses beyond those listed above may cause permanent damage to the device. this is a stress rating only, and functional operation of the c165h is not implied at these or any other conditions above those indicated in the operational sections of this specification. exposure to absolute maximum rating conditions for extended periods may affect device reliability. 23.2 recommended operating conditions the following conditions are to be met for correct operation of the device.  ambient temperature under bias ( t a ): -40 to +85 c  load capacitance ( c l ): < 100 pf 23.3 dc characteristics the parameters listed below partly represent the characteristics of the c165h and partly its demands on the system. to aid in interpreting the table correctly when evaluating parameters for a design, the following notation is used in the column ?symbol?: cc ( c ontroller c haracteristics): the logic of the c165h will provide signals with the respective timing characteristics. sr ( s ystem r equirement): the external system must provide signals with the respective timing characteristics to the c165h.
c165h ac/dc characteristics data sheet 472 2001-04-19 p r e l i m i n a r y - exc er p t - v dd = 3.3 v 10%; v ss = 0 v t a = -40 to 85 o c, nom = 25 o c 1) not tested; guaranteed by design characterization. 2) the maximum current may be drawn while the respective signal line remains inactive. 3) the minimum current must be drawn in order to drive the respective signal line active. table 77 dc characteristics parameter symbol values unit test condition min nom max power source current, normal operation i cc ? 100 150 ma 36 mhz system frequency 6) power source current, idle mode i id ? ? t.b.d. ma ? power source current, sleep mode i pd ? 140 ? a? power source current, power-down mode i pd ?25? a? input low voltage v ilsr -0.5 ? 0.8 v ? input high voltage v ihsr 2.2 ? 5.5 v v dd = 3.6 v v ihsr 2.0 ? v v dd = 3.3 v v ihsr 1.8 ? v v dd = 3.0 v output low voltage v olcc ??0.4 v i ol = 3.2 ma output high voltage v ohcc 2.4 ? ? v i oh = -3.2 ma input leakage current i oz2cc ?? 1 a 0 v < v in < v dd rstin pullup resistor r rstcc 100 ? 660 k ? at v dd = 3.3 v read/write inactive current 4) i rwh 2) ??-40 a v out = 2.4 v read/write active current 4) i rwl 3) -100 ? ? a v out = v olmax ale inactive current 4) i alel 2) ??40 a v out = v olmax ale active current 4) i aleh 3) 100 ? ? a v out = 2.4 v port 6 inactive current 4) i p6h 2) ??-40 a v out = 2.4 v port 6 active current 4) i p6l 3) -100 ? ? a v out = v olmax port 0 configuration current 4) i p0h 2) ??-10 a v in = v ihmin i p0l 3) -100 ? ? a v in = v ilmax xtal1 input current i ilcc ?? 20 a 0 v < v in < v dd xtal1 max input voltage 5) v ih2 1? v dd + 0.3 v ? pin capacitance 1) (digital inputs/outputs) c iocc ??9 pf f = 1 mhz; t a = 25 c
c165h ac/dc characteristics data sheet 473 2001-04-19 p r e l i m i n a r y - exc er pt - 4) this specification is only valid during reset or during adapt-mode. port 6 pins are affected only if they are used for cs output and the open drain function is not enabled. 5) not 5-v tolerant. 6) at a lower system frequency, the power consumption decreases accordingly. note: the sum of power from all port pins may not exceed 1 w; total i/o current may not exceed 250 ma. note: the strength of output drivers ( i ol and i oh ) is 7.5 ma. 23.4 failsafe operation c165h i/o pins may be exposed up to a 5.5 v level generated by the other system components. that may happen during operation in the normal power range as well as during power-up/down transitions when the value of vdd may be anywhere in the range from 0 v to 3.63 v. the following table specifies 5.5 v failsafe conditions for the different ranges of vdd. table 78 failsafe conditions vdd i/o status safe condition with 5.5 v applied to i/o pin note power-up not connected undetermined not to exceed 10 ma on any pin, 250 ma total _ 0 v - 2.97 v undetermined not to exceed 10 ma on any pin, 250 ma total _ normal power range 2.97 v - 3.63 v determined not to exceed 10 ma on any pin, 250 ma total _ power- down 2.97 v - 2.25 v determined not to exceed 10 ma on any pin, 250 ma total at 2.5 v 10% (power down mode) i/os are active and preserve the status 2.25 v - 0 undetermined not to exceed 10 ma on any pin, 250 ma total _
c165h ac/dc characteristics data sheet 474 2001-04-19 p r e l i m i n a r y - exc er p t - 23.5 testing waveforms figure 140 input output waveforms figure 141 float waveforms 23.6 ac characteristics the parameters in this chapter partly represent the characteristics of the c165h and partly its demands on the system. to aid in interpreting the table correctly when evaluating parameters for a design, the following notation is used in the column ?symbol?: cc ( c ontroller c haracteristics): the logic of the c165h will provide signals with the respective timing characteristics. sr ( s ystem r equirement): the external system must provide signals with the respective timing characteristics to the c165h. ac inputs during testing are driven at 2.4 v for a logic ?1? and 0.45 v for a logic ?0?. timing measurements are made at v ih min for a logic ?1? and v il max for a logic ?0?. 0.45 v 0.8 v 0.8 v 2.0 v 2.0 v test points 2.4 v for timing purposes a port pin is no longer floating when a 100 mv change from load voltage occurs, but begins to float when a 100 mv change from the loaded v oh / v ol l e v e l o c c u r s ( i oh / i ol = 20 ma). timing reference points v oh -0.1 v v ol +0.1 v v load +0.1 v v load -0.1 v
c165h ac/dc characteristics data sheet 475 2001-04-19 p r e l i m i n a r y - exc er pt - 23.6.1 definition of internal timing the internal operation of the c165h is controlled by the internal cpu clock f cpu . both edges of the cpu clock can trigger internal (eg. pipeline) or external (eg. bus cycles) operations. the specification of the external timing (ac characteristics) therefore depends on the time between two consecutive edges of the cpu clock, called ?tcl? (see figure 142 ). figure 142 generation mechanisms for the cpu clock the cpu clock signal can be generated via different mechanisms. the mechanism used to generate the cpu clock is selected during reset via the logic levels on pins p0.15-13 (p0h.7-5) and is described in detail in chapter 3.3 , page 36. the duration of tcls and their variation (and also the derived external timing) depends on the mechanism used to generate f cpu . this influence must be regarded when calculating the timings for the c165h. note: the example for pll operation shown in figure 142 refers to a pll factor of 4. the pll multiplies the input frequency by the factor f which is selected via the combination of pins p0.15-13 (ie. f cpu = f xtal * f ). with every f ?th transition of f xtal the pll circuit synchronizes the cpu clock to the input clock. this synchronization is done smoothly, i.e. the cpu clock frequency does not change abruptly. due to this adaptation to the input clock, the frequency of f cpu is constantly adjusted so it is locked to f xtal . the slight variation causes a jitter of f cpu which also affects the duration of individual tcls. the timings listed in the ac characteristics that refer to tcls therefore must be calculated using the minimum tcl that is possible under the respective circumstances. the actual minimum value for tcl depends on the jitter of the pll. as the pll is constantly adjusting its output frequency so it corresponds to the applied input frequency (crystal or oscillator), the relative deviation for periods of more than one tcl is lower f cpu f xtal phase locked loop operation tcl f cpu f xtal prescaler operation tcl tcl tcl
c165h ac/dc characteristics data sheet 476 2001-04-19 p r e l i m i n a r y - exc er p t - than for a single tcl. this is especially important for bus cycles using wait-states and for the operation of timers, serial interfaces, etc. for all slower operations and longer periods (eg. pulse train generation or measurement, lower baudrates, etc.), the deviation caused by the pll jitter is negligible. 23.6.2 system reset figure 143 reset input and output signals note: minimum reset time after power on is 1 ms after voltage reaches v dd minimum. delayed until the end of the internal reset condition. current bus cycle is completed or aborted. activation of the io pins is controlled by software. execution of the einit instruction. when the internal reset condition is extended by rstin, the activation of the output signals is switches asinchronously with rstin, sinchronously upon software or watchdog reset. the reset condition ends here. the c 167cr starts program execution. the shaded area designates the internal reset sequence, which starts after synchronization of rstin. rstin internal reset condition 6) initialization 3) mcs02258 rd, wr rstout io ale bus rstin internal reset condition 6) 1) 2) 2) initialization 3) 5) 4) 8) 7) a short hardware reset is extended until the end of the reset sequence in bidirectional reset mode. a software or wdt reset activates the rstin line in bidirectional reset mode. 8) 7) 6) 3) 2) 5) 4) 1)
c165h ac/dc characteristics data sheet 477 2001-04-19 p r e l i m i n a r y - exc er pt - 23.6.3 external clock drive xtal1 v dd = 3.3 v 10%; v ss = 0 v t a = -40 to +85 c note: special requirements for the external crystal must be observed: the accuracy of the crystal must be 96ppm or better. please note, the implemented low swing crystal oscillator has a signal amplitude of only about 1 v peak-to-peak. more detailed information can also be found in the appropriated application note. figure 144 external clock drive xtal1 table 79 external clock drive xtal 1 parameter sym bol external crystal: 4-20 mhz (internal oscillator "on", pll running) direct drive: 4-36 mhz (internal oscillator by-passed, pll "free running" or "off") unit min max min max oscillator period t oscsr 50 250 27.8 250 ns duty cycle - - 50 % high time t 1sr - - 13.9 125 ns low time t 2sr - - 13.9 125 ns rise time t 3sr - - - 3 @ 36 mhz ns fall time t 4sr - - - 3 @ 36 mhz ns mct02534 3 t 4 t v ih2 v il v dd 0.5 1 t 2 t osc t
c165h ac/dc characteristics data sheet 478 2001-04-19 p r e l i m i n a r y - exc er p t - 23.6.4 iom-2 interface timing table 80 timing characteristics of iom-2 interface note: the input data (fsc and input du and dd) are always sampled with the falling edge of dcl/bcl. in case of dcl - fsc is sampled with the first falling edge and du/dd are sampled with the second falling edge of the bit frame. parameter cc / sr symbol limit values unit min. max. dcl, bcl data clock sr t r , t f 60 ns dcl, bcl clock period sr t dcl , t bcl 110 ns dcl, bcl pulse width sr t wh , t wl 53 ns fsc frame sync sr t r , t f 60 ns fsc frame setup sr t sf_dcl , t sf_bcl 70 ns fsc frame hold sr t hf_dcl , t hf_bcl 40 ns dout data delay/clock cc t ddc 100 1) 1) condition: c l = 150 pf ns dout data setup sr t sd t wh + 20 ns dout data hold sr t hd 50 150 ns
c165h ac/dc characteristics data sheet 479 2001-04-19 p r e l i m i n a r y - exc er pt - figure 145 iom-2 interface timing bcl dcl fsc du/dd bit 0 bcl dcl fsc du/dd du/dd output input (dcl) t r t f t f t hf_dcl t sf_dcl t ddc t sf_bcl t hf_bcl t hd t sd bit 0 bit 1 bit n t wh t wh t wl t wl t dcl t bcl t sd t hd du/dd input (bcl)
c165h ac/dc characteristics data sheet 480 2001-04-19 p r e l i m i n a r y - exc er p t - 23.6.5 jtag interface timing  figure 146 jtag interface timing table 81 jtag interface timing no. parameter limit values unit min. max. 200 tck period 120 ns 201 tck high time 60 ns 202 tck low time 60 ns 203 tms setup time 20 ns 204 tms hold time 20 ns 205 tdi setup time 20 ns 206 tdi hold time 20 ns 207 tdo valid time 50 ns trst tck tms tdi tdo 202 201 200 203 204 205 206 207
c165h ac/dc characteristics data sheet 481 2001-04-19 p r e l i m i n a r y - exc er pt - 23.7 asynchronous bus timing this term means that timing is defined with respect to ale (as opposed to clkout). the following configurations are typical : 23.7.1 memory cycle variables the timing tables below use 4 variables which are derived from the busconx registers and represent the special characteristics of the programmed memory cycle. the following table describes, how these variables are to be computed. 23.7.1.1 ac characteristics, multiplexed bus v dd = 3.3 v 10 %; v ss = 0 v t a = -40 to +85 c c l (for port0, port1, port 4, ale, rd , wr , bhe , clkout) = 100 pf c l (for port 6, cs ) = 100 pf ale cycle time = 6 tcl + 2 t a + t c + t f (83.3 ns at 36 mhz cpu clock without wait states) table 82 asynchronous bus timing rdy ale wr mttc rd/wr mctc cycles application buscon no normal early no normal no 2 srams demuxed bus 0a3f (8) or 0abf(16) no normal - no normal 1 3 fast eproms demuxed bus 0a3e / 0abe no normal - 1 normal 2 5 slow flash demuxed bus 0a1d / 0a9d no normal normal no delayed no 2+1 srams muxed bus 04ef / 046f no normal - no delayed 1 3+1 fast eproms muxed bus 04ee / 046e no normal - no delayed 2 4+1 slow flash muxed bus 04ed / 046d table 83 memory cycle variables description symbol values ale extension t a tcl * memory cycle time waitstates t c 2tcl * (15 - ) memory tristate time t f 2tcl * (1 - ) early write t w tcl *
c165h ac/dc characteristics data sheet 482 2001-04-19 p r e l i m i n a r y - exc er p t - table 84 ac characteristics, multiplexed bus parameter symbol max. cpu clock 36 mhz (tcl=14ns) variable cpu clock 5 to 36 mhz unit min. max. min. max. ale high time t 5 cc 4 + t a ? tcl - 10 + t a ? ns address , csx 2) setup to ale t 6 cc -6 + t a ? tcl - 20 + t a ? ns address hold after ale t 7 cc 4 + t a tcl - 10 + t a ns ale falling edge to rd , wr (with rw-delay) t 8 cc 4 + t a ? tcl - 10 + t a ? ns ale falling edge to rd , wr (no rw-delay) t 9 cc -10 + t a ? -10 + t a ? ns address float after rd, wr (with rw-delay) t 10 cc ? 15 ? 15 ns address float after rd , wr (no rw-delay) t 11 cc ? 29 ? tcl + 15 ns rd , wr low time (with rw-delay) 3) t 12 cc 17 + t c - t w ? 2tcl - 11 + t c - t w ? ns rd , wr low time (no rw-delay) 3) t 13 cc 31 + t c - t w ? 3tcl - 11 + t c - t w ? ns rd to valid data in (with rw-delay) t 14 sr ? 0 + t c ? 2tcl - 28 + t c ns rd to valid data in (no rw-delay) t 15 sr ? 13 + t c ? 3tcl - 29 + t c ns ale low to valid data in t 16 sr ? 13 + t a + t c ? 3tcl - 29 + t a + t c ns address , csx 2) to valid data in t 17 sr ? 18 + 2 t a + t c ? 4tcl - 38 + 2 t a + t c ns data hold after rd rising edge t 18 sr 0 ? 0 ? ns data float after rd t 19 sr ? 13 + t f ? 2tcl - 15 + t f ns data valid to wr t 22 cc 13 + t c - t w ? 2tcl - 15 + t c - t w ? ns data hold after wr t 23 cc 13 + t f + t w ? 2tcl - 15 + t f + t w ? ns ale rising edge after rd , wr 3) t 25 cc 13 + t f + t w ? 2tcl - 15 + t f + t w ? ns
c165h ac/dc characteristics data sheet 483 2001-04-19 p r e l i m i n a r y - exc er pt - 1) normal (latched) cs: bit cscfg, register syscon.6, is set to ?0?, latched mode is selcted. 2) early (unlatched) cs ; (bit cscfg = ?1?) while address bus is changing spikes may occur on cs in this mode. 3) the memory cycle variable t w applies only for write accesses; for read accesses this variable is always zero. address hold after rd , wr 3) t 27 cc 13 + t f + t w ?2tcl - 15 + t f + t w ?ns ale falling edge to csx 1) t 38 cc -9 - t a 13 - t a -9 - t a 13 - t a ns csx 1) low to valid data in t 39 sr ?12 + t c + 2 t a ? 3tcl - 30 + t c +2 t a ns csx 1) hold after rd , wr 3) t 40 cc 27 + t f + t w ?3tcl - 15 + t f + t w ?ns ale falling edge to rdcs , wrcs (with rw delay) t 42 cc 5 + t a ?tcl - 9 + t a ?ns ale falling edge to rdcs , wrcs (no rw delay) t 43 cc -9 + t a ?-9 + t a ?ns address float after rdcs , wrcs (with rw delay) t 44 cc ? 13 ? 13 ns address float after rdcs , wrcs (no rw delay) t 45 cc ? 27 ? tcl + 13 ns rdcs to valid data in (with rw delay) t 46 sr ?-4 + t c ? 2tcl - 32 + t c ns rdcs to valid data in (no rw delay) t 47 sr ?10 + t c ? 3tcl - 32 + t c ns rdcs , wrcs low time (with rw delay) 3) t 48 cc 14 + t c - t w ? 2tcl - 14 + t c - t w ?ns rdcs , wrcs low time (no rw delay) 3) t 49 cc 30 + t c - t w ? 3tcl - 12 + t c - t w ?ns data valid to wrcs t 50 cc 13 + t c - t w ? 2tcl - 15 + t c - t w ?ns data hold after rdcs t 51 sr 0?0 ? ns data float after rdcs t 52 sr ?7 + t f ? 2tcl - 21 + t f ns address hold after rdcs , wrcs 3) t 54 cc 8 + t f + t w ?2tcl - 20 + t f + t w ?ns data hold after wrcs t 56 cc 8 + t f + t w ?2tcl - 20 + t f + t w ?ns table 84 ac characteristics, multiplexed bus (cont?d) parameter symbol max. cpu clock 36 mhz (tcl=14ns) variable cpu clock 5 to 36 mhz unit min. max. min. max.
c165h ac/dc characteristics data sheet 484 2001-04-19 p r e l i m i n a r y - exc er p t - figure 147 external memory cycle: multiplexed bus, with read/write delay, normal ale data in data out address address t 38 t 44 t 10 address ale bus read cycle rd rdcsx bus write cycle wr, wrl, wrh wrcsx t 5 t 16 t 17 t 6 t 7 t 39 t 25 t 18 t 19 t 14 t 46 t 12 t 48 t 10 t 22 t 23 t 44 t 12 t 48 t 8 t 42 t 42 t 8 t 50 t 51 t 52 t 56 t 27 t 40 t 54 csx 1) a23-a16 (a15-a8) csx 2) , bhe
c165h ac/dc characteristics data sheet 485 2001-04-19 p r e l i m i n a r y - exc er pt - figure 148 external memory cycle: multiplexed bus, with read/write delay, extended ale data out address data in address t 38 t 44 t 10 address ale bus read cycle rd rdcsx bus write cycle wr, wrl, wrh wrcsx t 5 t 16 t 17 t 6 t 7 t 39 t 25 t 18 t 19 t 14 t 46 t 12 t 10 t 22 t 23 t 44 t 12 t 8 t 42 t 42 t 8 t 50 t 51 t 52 t 56 t 27 t 40 t 54 t 48 t 48 csx 1) a23-a16 (a15-a8) csx 2) , bhe
c165h ac/dc characteristics data sheet 486 2001-04-19 p r e l i m i n a r y - exc er p t - figure 149 external memory cycle: multiplexed bus, no read/write delay, normal ale data out address address data in t 38 address ale csx 1) a23-a16 (a15-a8) csx 2) ,bhe bus read cycle rd rdcsx bus write cycle wr, wrl, wrh wrcsx t 5 t 16 t 17 t 6 t 7 t 39 t 18 t 19 t 15 t 47 t 13 t 49 t 22 t 23 t 13 t 49 t 9 t 43 t 43 t 9 t 11 t 45 t 11 t 45 t 50 t 51 t 52 t 56 t 25 t 27 t 40 t 54
c165h ac/dc characteristics data sheet 487 2001-04-19 p r e l i m i n a r y - exc er pt - figure 150 external memory cycle: multiplexed bus, no read/write delay, extended ale data out address data in address t 38 address ale csx 1) a23-a16 (a15-a8) csx 2) ,bhe bus read cycle rd rdcsx bus write cycle wr, wrl, wrh wrcsx t 5 t 16 t 17 t 6 t 7 t 39 t 25 t 18 t 19 t 15 t 47 t 13 t 49 t 22 t 23 t 13 t 49 t 9 t 43 t 43 t 9 t 11 t 45 t 11 t 45 t 50 t 51 t 52 t 56 t 27 t 40 t 54
c165h ac/dc characteristics data sheet 488 2001-04-19 p r e l i m i n a r y - exc er p t - 23.7.1.2 ac characteristics, demultiplexed bus v dd = 3.3 v 10 %; v ss = 0 v t a = -40 to +85 c c l (for port0, port1, port 4, ale, rd , wr , bhe , clkout) = 100 pf c l (for port 6, cs ) = 100 pf ale cycle time = 4 tcl + 2 t a + t c + t f (55.5 ns at 36 mhz cpu clock without waitstates) table 85 ac characteristics, demultiplexed bus parameter symbol max. cpu clock = 36 mhz (tcl=14ns) variable cpu clock 5 to 36 mhz unit min. max. min. max. ale high time t 5 cc 4 + t a ? tcl - 10 + t a ?ns address , csx 4) setup to ale t 6 cc -6 + t a ? tcl - 20 + t a ?ns ale falling edge to rd , wr (with rw-delay) t 8 cc 4 + t a ? tcl - 10 + t a ?ns ale falling edge to rd , wr (no rw-delay) t 9 cc -10 + t a ? -10 + t a ?ns rd , wr low time (with rw-delay) 6) t 12 cc 17 + t c - t w ? 2tcl - 11 + t c - t w ?ns rd , wr low time (no rw- delay) 6) t 13 cc 31 + t c - t w ? 3tcl - 11 + t c - t w ?ns rd to valid data in (with rw-delay) t 14 sr ?0 + t c ? 2tcl - 28 + t c ns rd to valid data in (no rw-delay) t 15 sr ? 13 + t c ? 3tcl - 29 + t c ns ale low to valid data in t 16 sr ? 13 + t a + t c ? 3tcl - 29 + t a + t c ns address , csx 4) to valid data in t 17 sr ? 16 + 2 t a + t c ? 4tcl - 40 + 2 t a + t c ns data hold after rd rising edge t 18 sr 0?0 ? ns data float after rd rising edge (with rw-delay 1) ) t 20 sr ? 14 + t f ? 2tcl - 14 + 2 t a + t f 1) ns data float after rd rising edge (no rw-delay 1) ) t 21 sr ?4 + t f ?tcl - 10 + 2 t a + t f 1) ns data valid to wr t 22 cc 13 + t c - t w ? 2tcl - 15 + t c - t w ?ns data hold after wr t 24 cc 4 + t f + t w ? tcl - 10 + t f + t w ?ns
c165h ac/dc characteristics data sheet 489 2001-04-19 p r e l i m i n a r y - exc er pt - 1) rw-delay and t a refer to the next following bus cycle. ale rising edge after rd , wr 6) t 26 cc 0 + t f + t w ?0 + t f + t w ?ns address, csx 4) hold after wr 2) 5) t 28 cc 0 + t f + t w ?0 + t f + t w ?ns ale falling edge to csx 3) t 38 cc -9 - t a 13 - t a -9 - t a 13 - t a ns csx 3) low to valid data in t 39 sr ? 12 + t c + 2 t a ? 3tcl - 30 + t c +2 t a ns csx 3) hold after rd , wr 6) t 41 cc 0 + t f + t w ?tcl - 14 + t f + t w ?ns ale falling edge to rdcs , wrcs (with rw- delay) t 42 cc 5 + t a ?tcl - 9 + t a ?ns ale falling edge to rdcs , wrcs (no rw- delay) t 43 cc -9 + t a ?-9 + t a ?ns rdcs to valid data in (with rw-delay) t 46 sr ?-4 + t c ? 2tcl - 32 + t c ns rdcs to valid data in (no rw-delay) t 47 sr ? 10 + t c ?3tcl - 32 + t c ns rdcs , wrcs low time (with rw-delay) 6) t 48 cc 14 + t c - t w ? 2tcl - 14 + t c - t w ?ns rdcs , wrcs low time (no rw-delay) 6) t 49 cc 30 + t c - t w ? 3tcl - 12 + t c - t w ?ns data valid to wrcs t 50 cc 13 + t c - t w ? 2tcl - 15 + t c - t w ?ns data hold after rdcs t 51 sr 0?0 ? ns data float after rdcs (with rw-delay 1) ) t 53 sr ?7 + t f ? 2tcl - 21 + t f ns data float after rdcs (no rw-delay 1) ) t 68 sr ?0 + t f ? tcl - 14 + t f ns address hold after wrcs 2) t 55 cc -14 + t f + t w ? - 14 + t f + t w ?ns data hold after wrcs t 57 cc 0 + t f + t w ?tcl - 14 + t f + t w ?ns table 85 ac characteristics, demultiplexed bus (cont?d) parameter symbol max. cpu clock = 36 mhz (tcl=14ns) variable cpu clock 5 to 36 mhz unit min. max. min. max.
c165h ac/dc characteristics data sheet 490 2001-04-19 p r e l i m i n a r y - exc er p t - 2) read data are latched with the same clock edge that triggers the address change and the rising rd , rdcs edge. therefore address changes before the end of rd , rdcs have no impact on read cycles. 3) normal (latched) cs: bit cscfg, register syscon.6, is set to ?0?, latched mode is selcted. 4) early (unlatched) cs (bit cscfg = ?1?) ; while address bus is changing spikes may occur on cs in this mode. 5) demultiplexed cycles: in case of early (unlatched) cs together with normal write (not early write) cs may go inactive 3 ns before the rising edge of wr . 6) the memory cycle variable t w applies only for write accesses; for read accesses this variable is always zero.
c165h ac/dc characteristics data sheet 491 2001-04-19 p r e l i m i n a r y - exc er pt - figure 151 external memory cycle: demultiplexed bus, with read/write delay, normal ale data out data in t 38 address ale csx 3) a23-a16 a15-a0 csx 4) , bhe bus (d15-d8) d7-d0 read cycle rd rdcsx write cycle wrcsx t 5 t 16 t 17 t 6 t 39 t 28 t 18 t 20 t 14 t 46 t 12 t 48 t 22 t 24 t 12 t 48 t 8 t 42 t 42 t 8 t 50 t 51 t 55 t 53 t 57 bus (d15-d8) d7-d0 wr, wrl, wrh t 26 t 41
c165h ac/dc characteristics data sheet 492 2001-04-19 p r e l i m i n a r y - exc er p t - figure 152 external memory cycle: demultiplexed bus, with read/write delay, extended ale data out data in t 38 address ale csx 3) a23-a16 a15-a0 csx 4), bhe read cycle rd rdcsx write cycle wrcsx t 5 t 16 t 17 t 6 t 39 t 28 t 18 t 20 t 14 t 46 t 12 t 48 t 22 t 24 t 12 t 48 t 8 t 42 t 42 t 8 t 50 t 51 t 55 t 53 t 57 bus (d15-d8) d7-d0 bus (d15-d8) d7-d0 wr, wrl, wrh t 26 t 41
c165h ac/dc characteristics data sheet 493 2001-04-19 p r e l i m i n a r y - exc er pt - figure 153 external memory cycle: demultiplexed bus, no read/write delay, normal ale data out data in t 38 address ale csx 3) a23-a16 a15-a0 csx 4) ,bhe read cycle rd rdcsx write cycle wrcsx t 5 t 16 t 17 t 6 t 39 t 28 t 18 t 21 t 15 t 47 t 13 t 49 t 22 t 24 t 13 t 49 t 9 t 43 t 43 t 9 t 50 t 51 t 55 t 68 t 57 bus (d15-d8) d7-d0 bus (d15-d8) d7-d0 wr, wrl,wrh t 26 t 41
c165h ac/dc characteristics data sheet 494 2001-04-19 p r e l i m i n a r y - exc er p t - figure 154 external memory cycle: demultiplexed bus, no read/write delay, extended ale data out data in t 38 address ale csx 3) a23-a16 a15-a0 csx 4) ,bhe read cycle rd rdcsx write cycle wr, wrl, wrh wrcsx t 5 t 16 t 17 t 6 t 39 t 28 t 18 t 21 t 15 t 47 t 13 t 49 t 22 t 24 t 13 t 49 t 9 t 43 t 43 t 9 t 50 t 51 t 55 t 68 t 57 bus (d15-d8) d7-d0 bus (d15-d8) d7-d0 t 26 t 41
c165h ac/dc characteristics data sheet 495 2001-04-19 p r e l i m i n a r y - exc er pt - 23.7.1.3 ac characteristics, clkout and ready v dd = 3.3 v 10 %; v ss = 0 v t a = -40 to +85 c c l (for port0, port1, port 4, ale, rd , wr , bhe , clkout, ready ) = 100 pf c l (for port 6, cs ) = 100 pf note: timing parameters for 36-mhz clock are based on the assumption that the oscillator is running at 8 mhz and pll with f = 4.5. 1) these timings are given for test purposes only, in order to assure recognition at a specific clock edge. 2) demultiplexed bus is the worst case. for multiplexed bus, 2 tcl is to be added to the maximum values. this adds even more time for deactivating ready . note: the 2 t a and t c refer to the next following bus cycle, t f refers to the current bus cycle. table 1 ac characteristics, clkout and ready parameter symbol cpu clock 36 mhz (tcl = 14ns) variable cpu clock 5 to 36 mhz unit min. max. min. max. clkout cycle time t 29 cc 27 29 2tcl - 1 2tcl + 1 ns clkout high time t 30 cc 8 ? tcl ? 6 ? ns clkout low time t 31 cc 4 ? tcl ? 10 ? ns clkout rise time t 32 cc ?4 ? 4 ns clkout fall time t 33 cc ?4 ? 4 ns clkout rising edge to ale falling edge t 34 cc 0 + t a 16 + t a 0 + t a 16 + t a ns synchronous ready setup time to clkout t 35 sr 18 ? 18 ? ns synchronous ready hold time after clkout t 36 sr 0? 0 ? ns asynchronous ready low time t 37 sr 45 ? 2tcl + 17 ?ns asynchronous ready setup time 1) t 58 sr 18 ? 18 ? ns asynchronous ready hold time 1) t 59 sr 0? 0 ? ns async. ready hold time after rd , wr high (demultiplexed bus) 2) t 60 sr 0 -10 + 2 t a + t c + t f 2) 0tcl - 24 + 2 t a + t c + t f 2) ns
c165h ac/dc characteristics data sheet 496 2001-04-19 p r e l i m i n a r y - exc er p t - figure 155 clkout and ready 1) cycle as programmed, including mctc wait states (example shows 0 mctc ws). 2) the leading edge of the respective command depends on rw-delay. 3) ready sampled high at this sampling point generates a ready controlled wait state. ready sampled low at this sampling point terminates the bus cycle currently running. 4) ready may be deactivated in response to the trailing (rising) edge of the corresponding command (rd or wr ). 5) if the asynchronous ready signal does not fulfill the indicated setup and hold times with respect to clkout (eg. because clkout is not enabled), it must fulfill t 37 in order to be safely synchronized. this is guaranteed if ready is removed in reponse to the command (see note 4) ). 6) multiplexed bus modes have a mux wait state added after a bus cycle, and an additional mttc wait state may be inserted here. for a multiplexed bus with mttc wait state, this delay is 2 clkout cycles, for a demultiplexed bus without mttc wait state this delay is zero. 7) the next external bus cycle may start here. clkout ale t 30 t 34 sync ready t 35 t 36 t 35 t 36 async ready t 58 t 59 t 58 t 59 waitstate ready mux/tristate 6) t 32 t 33 t 29 running cycle 1) t 31 t 37 3) 3) 5) command rd, wr t 60 4) see 6) 2) 7) 3) 3)
c165h package outline data sheet 497 2001-04-19 p r e l i m i n a r y - exc er pt - 24 package outline p-tqfp-144 (plastic thin quad flat package)
c165h package outline data sheet 498 2001-04-19 p r e l i m i n a r y - exc er p t -
http://www.infineon.com published by infineon technologies ag infineon goes for business excellence ? business excellence means intelligent approaches and clearly defined processes, which are both constantly under review and ultimately lead to good operating results. better operating results and business excellence mean less idleness and wastefulness for all of us, more professional success, more accurate information, a better overview and, thereby, less frustration and more satisfaction. ? dr. ulrich schumacher


▲Up To Search▲   

 
Price & Availability of SAFC165H-LFV13

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X